Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b53f701c
Commit
b53f701c
authored
Jun 22, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/fetcher: remove test sleeps (15s -> 2.8s)
parent
1989d149
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
59 deletions
+167
-59
fetcher.go
eth/fetcher/fetcher.go
+16
-1
fetcher_test.go
eth/fetcher/fetcher_test.go
+151
-58
No files found.
eth/fetcher/fetcher.go
View file @
b53f701c
...
...
@@ -92,6 +92,10 @@ type Fetcher struct {
chainHeight
chainHeightFn
// Retrieves the current chain's height
insertChain
chainInsertFn
// Injects a batch of blocks into the chain
dropPeer
peerDropFn
// Drops a peer for misbehaving
// Testing hooks
fetchingHook
func
([]
common
.
Hash
)
// Method to call upon starting a block fetch
importedHook
func
(
*
types
.
Block
)
// Method to call upon successful block import
}
// New creates a block fetcher to retrieve blocks based on hash announcements.
...
...
@@ -277,7 +281,13 @@ func (f *Fetcher) loop() {
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Peer %s: fetching %s"
,
peer
,
list
)
}
go
f
.
fetching
[
hashes
[
0
]]
.
fetch
(
hashes
)
hashes
:=
hashes
// closure!
go
func
()
{
if
f
.
fetchingHook
!=
nil
{
f
.
fetchingHook
(
hashes
)
}
f
.
fetching
[
hashes
[
0
]]
.
fetch
(
hashes
)
}()
}
// Schedule the next fetch if blocks are still pending
f
.
reschedule
(
fetch
)
...
...
@@ -402,6 +412,11 @@ func (f *Fetcher) insert(peer string, block *types.Block) {
}
// If import succeeded, broadcast the block
go
f
.
broadcastBlock
(
block
,
false
)
// Invoke the testing hook if needed
if
f
.
importedHook
!=
nil
{
f
.
importedHook
(
block
)
}
}()
}
...
...
eth/fetcher/fetcher_test.go
View file @
b53f701c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment