Skip to content

Commit

Permalink
eth/protocols/eth: handle zero-count header requests (ethereum#30305)
Browse files Browse the repository at this point in the history
Proper fix for handling `count=0` get header requests. 

https://en.wikipedia.org/wiki/Count_Zero
  • Loading branch information
holiman committed Aug 21, 2024
1 parent df645e7 commit 733fcbb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 733fcbb

Please sign in to comment.