eth/protocols/eth: handle zero-count header requests (#30305)

Proper fix for handling `count=0` get header requests. 

https://en.wikipedia.org/wiki/Count_Zero
pull/30335/head
Martin HS 3 months ago committed by GitHub
parent df645e77b7
commit 733fcbbc65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      eth/protocols/eth/handlers.go

@ -42,6 +42,9 @@ func handleGetBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
// ServiceGetBlockHeadersQuery assembles the response to a header query. It is
// exposed to allow external packages to test protocol behavior.
func ServiceGetBlockHeadersQuery(chain *core.BlockChain, query *GetBlockHeadersRequest, peer *Peer) []rlp.RawValue {
if query.Amount == 0 {
return nil
}
if query.Skip == 0 {
// The fast path: when the request is for a contiguous segment of headers.
return serviceContiguousBlockHeaderQuery(chain, query)

Loading…
Cancel
Save