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
355b1e3b
Commit
355b1e3b
authored
Jun 10, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: randomly fetch announced block (don't hammer origin)
parent
b9affbf9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
sync.go
eth/sync.go
+5
-4
No files found.
eth/sync.go
View file @
355b1e3b
...
...
@@ -127,7 +127,7 @@ func (pm *ProtocolManager) txsyncLoop() {
// fetcher is responsible for collecting hash notifications, and periodically
// checking all unknown ones and individually fetching them.
func
(
pm
*
ProtocolManager
)
fetcher
()
{
announces
:=
make
(
map
[
common
.
Hash
]
*
blockAnnounce
)
announces
:=
make
(
map
[
common
.
Hash
]
[]
*
blockAnnounce
)
request
:=
make
(
map
[
*
peer
][]
common
.
Hash
)
pending
:=
make
(
map
[
common
.
Hash
]
*
blockAnnounce
)
cycle
:=
time
.
Tick
(
notifyCheckCycle
)
...
...
@@ -139,7 +139,7 @@ func (pm *ProtocolManager) fetcher() {
// A batch of hashes the notified, schedule them for retrieval
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Scheduling %d hash announcements from %s"
,
len
(
notifications
),
notifications
[
0
]
.
peer
.
id
)
for
_
,
announce
:=
range
notifications
{
announces
[
announce
.
hash
]
=
a
nnounce
announces
[
announce
.
hash
]
=
a
ppend
(
announces
[
announce
.
hash
],
announce
)
}
case
<-
cycle
:
...
...
@@ -150,8 +150,9 @@ func (pm *ProtocolManager) fetcher() {
}
}
// Check if any notified blocks failed to arrive
for
hash
,
announce
:=
range
announces
{
if
time
.
Since
(
announce
.
time
)
>
notifyArriveTimeout
{
for
hash
,
all
:=
range
announces
{
if
time
.
Since
(
all
[
0
]
.
time
)
>
notifyArriveTimeout
{
announce
:=
all
[
rand
.
Intn
(
len
(
all
))]
if
!
pm
.
chainman
.
HasBlock
(
hash
)
{
request
[
announce
.
peer
]
=
append
(
request
[
announce
.
peer
],
hash
)
pending
[
hash
]
=
announce
...
...
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