Relinquish peerLock when blockFetcher context is done (#10932)

* Relinquish peerLock when blockFetcher context is done

* Unlock before sending range requests

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
Murphy Law 2022-06-27 11:25:33 -04:00 committed by GitHub
parent 3a841a8467
commit dfe8e54a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,6 +318,7 @@ func (f *blocksFetcher) requestBlocks(
}).Debug("Requesting blocks")
if f.rateLimiter.Remaining(pid.String()) < int64(req.Count) {
if err := f.waitForBandwidth(pid); err != nil {
l.Unlock()
return nil, err
}
}
@ -345,6 +346,7 @@ func (f *blocksFetcher) requestBlocksByRoot(
}).Debug("Requesting blocks (by roots)")
if f.rateLimiter.Remaining(pid.String()) < int64(len(*req)) {
if err := f.waitForBandwidth(pid); err != nil {
l.Unlock()
return nil, err
}
}