Skip to content

Commit 733fcbb

Browse files
authored
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
1 parent df645e7 commit 733fcbb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

eth/protocols/eth/handlers.go

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

0 commit comments

Comments
 (0)