Another fix for stuck header download (#4433)

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2022-06-11 08:13:40 +01:00 committed by GitHub
parent 8e3ac8a21c
commit 1cc5b92dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View File

@ -418,11 +418,10 @@ func (cs *MultiClient) blockHeaders(ctx context.Context, pkt eth.BlockHeadersPac
req, penalties := cs.Hd.RequestMoreHeaders(currentTime)
if req != nil {
if _, sentToPeer := cs.SendHeaderRequest(ctx, req); sentToPeer {
// If request was actually sent to a peer, we update retry time to be 5 seconds in the future
cs.Hd.UpdateRetryTime(req, currentTime, 5*time.Second /* timeout */)
log.Trace("Sent request", "height", req.Number)
cs.Hd.UpdateStats(req, false /* skeleton */)
}
// Regardless of whether request was actually sent to a peer, we update retry time to be 5 seconds in the future
cs.Hd.UpdateRetryTime(req, currentTime, 5*time.Second /* timeout */)
}
if len(penalties) > 0 {
cs.Penalize(ctx, penalties)

View File

@ -738,10 +738,10 @@ Loop:
if req != nil {
_, sentToPeer = cfg.headerReqSend(ctx, req)
if sentToPeer {
// If request was actually sent to a peer, we update retry time to be 5 seconds in the future
cfg.hd.UpdateRetryTime(req, currentTime, 5*time.Second /* timeout */)
log.Trace("Sent request", "height", req.Number)
cfg.hd.UpdateStats(req, false /* skeleton */)
}
// Regardless of whether request was actually sent to a peer, we update retry time to be 5 seconds in the future
cfg.hd.UpdateRetryTime(req, currentTime, 5*time.Second /* timeout */)
}
if len(penalties) > 0 {
cfg.penalize(ctx, penalties)
@ -752,12 +752,10 @@ Loop:
if req != nil {
_, sentToPeer = cfg.headerReqSend(ctx, req)
if sentToPeer {
// If request was actually sent to a peer, we update retry time to be 5 seconds in the future
cfg.hd.UpdateRetryTime(req, currentTime, 5*time.Second /*timeout */)
log.Trace("Sent request", "height", req.Number)
cfg.hd.UpdateStats(req, false /* skeleton */)
}
// Regardless of whether request was actually sent to a peer, we update retry time to be 5 seconds in the future
cfg.hd.UpdateRetryTime(req, currentTime, 5*time.Second /* timeout */)
}
if len(penalties) > 0 {
cfg.penalize(ctx, penalties)
@ -771,7 +769,6 @@ Loop:
if req != nil {
_, sentToPeer = cfg.headerReqSend(ctx, req)
if sentToPeer {
log.Trace("Sent skeleton request", "height", req.Number)
cfg.hd.UpdateStats(req, true /* skeleton */)
lastSkeletonTime = time.Now()
}