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
7e2bbb9c
Unverified
Commit
7e2bbb9c
authored
Apr 06, 2022
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/fetcher: if peers never respond, drop them
parent
28ec2609
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
8 deletions
+31
-8
block_fetcher.go
eth/fetcher/block_fetcher.go
+31
-8
No files found.
eth/fetcher/block_fetcher.go
View file @
7e2bbb9c
...
...
@@ -477,10 +477,21 @@ func (f *BlockFetcher) loop() {
}
defer
req
.
Close
()
res
:=
<-
resCh
res
.
Done
<-
nil
f
.
FilterHeaders
(
peer
,
*
res
.
Res
.
(
*
eth
.
BlockHeadersPacket
),
time
.
Now
()
.
Add
(
res
.
Time
))
timeout
:=
time
.
NewTimer
(
2
*
fetchTimeout
)
// 2x leeway before dropping the peer
defer
timeout
.
Stop
()
select
{
case
res
:=
<-
resCh
:
res
.
Done
<-
nil
f
.
FilterHeaders
(
peer
,
*
res
.
Res
.
(
*
eth
.
BlockHeadersPacket
),
time
.
Now
()
.
Add
(
res
.
Time
))
case
<-
timeout
.
C
:
// The peer didn't respond in time. The request
// was already rescheduled at this point, we were
// waiting for a catchup. With an unresponsive
// peer however, it's a protocol violation.
f
.
dropPeer
(
peer
)
}
}(
hash
)
}
}(
peer
)
...
...
@@ -523,11 +534,23 @@ func (f *BlockFetcher) loop() {
}
defer
req
.
Close
()
res
:=
<-
resCh
res
.
Done
<-
nil
timeout
:=
time
.
NewTimer
(
2
*
fetchTimeout
)
// 2x leeway before dropping the peer
defer
timeout
.
Stop
()
select
{
case
res
:=
<-
resCh
:
res
.
Done
<-
nil
txs
,
uncles
:=
res
.
Res
.
(
*
eth
.
BlockBodiesPacket
)
.
Unpack
()
f
.
FilterBodies
(
peer
,
txs
,
uncles
,
time
.
Now
())
txs
,
uncles
:=
res
.
Res
.
(
*
eth
.
BlockBodiesPacket
)
.
Unpack
()
f
.
FilterBodies
(
peer
,
txs
,
uncles
,
time
.
Now
())
case
<-
timeout
.
C
:
// The peer didn't respond in time. The request
// was already rescheduled at this point, we were
// waiting for a catchup. With an unresponsive
// peer however, it's a protocol violation.
f
.
dropPeer
(
peer
)
}
}(
peer
,
hashes
)
}
// Schedule the next fetch if blocks are still pending
...
...
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