mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-06 01:47:29 +00:00
eth/protocols/snap: restore Bytes soft limit to GetAccessListsPacket (#34649)
This PR adds Bytes field back to GetAccesListsPacket
This commit is contained in:
parent
00da4f51ff
commit
a608ac94ec
3 changed files with 9 additions and 1 deletions
|
|
@ -80,6 +80,7 @@ func TestServiceGetAccessListsQuery(t *testing.T) {
|
|||
req := &GetAccessListsPacket{
|
||||
ID: 1,
|
||||
Hashes: hashes,
|
||||
Bytes: softResponseLimit,
|
||||
}
|
||||
result := ServiceGetAccessListsQuery(bc, req)
|
||||
|
||||
|
|
@ -105,6 +106,7 @@ func TestServiceGetAccessListsQueryEmpty(t *testing.T) {
|
|||
req := &GetAccessListsPacket{
|
||||
ID: 2,
|
||||
Hashes: mixed,
|
||||
Bytes: softResponseLimit,
|
||||
}
|
||||
result := ServiceGetAccessListsQuery(bc, req)
|
||||
|
||||
|
|
@ -147,6 +149,7 @@ func TestServiceGetAccessListsQueryCap(t *testing.T) {
|
|||
req := &GetAccessListsPacket{
|
||||
ID: 3,
|
||||
Hashes: hashes,
|
||||
Bytes: softResponseLimit,
|
||||
}
|
||||
result := ServiceGetAccessListsQuery(bc, req)
|
||||
|
||||
|
|
@ -171,6 +174,7 @@ func TestServiceGetAccessListsQueryByteLimit(t *testing.T) {
|
|||
req := &GetAccessListsPacket{
|
||||
ID: 0,
|
||||
Hashes: hashes,
|
||||
Bytes: softResponseLimit,
|
||||
}
|
||||
result := ServiceGetAccessListsQuery(bc, req)
|
||||
|
||||
|
|
|
|||
|
|
@ -569,6 +569,9 @@ func handleGetAccessLists(backend Backend, msg Decoder, peer *Peer) error {
|
|||
// ServiceGetAccessListsQuery assembles the response to an access list query.
|
||||
// It is exposed to allow external packages to test protocol behavior.
|
||||
func ServiceGetAccessListsQuery(chain *core.BlockChain, req *GetAccessListsPacket) []rlp.RawValue {
|
||||
if req.Bytes > softResponseLimit {
|
||||
req.Bytes = softResponseLimit
|
||||
}
|
||||
// Cap the number of lookups
|
||||
if len(req.Hashes) > maxAccessListLookups {
|
||||
req.Hashes = req.Hashes[:maxAccessListLookups]
|
||||
|
|
@ -585,7 +588,7 @@ func ServiceGetAccessListsQuery(chain *core.BlockChain, req *GetAccessListsPacke
|
|||
// Either the block is unknown or the BAL doesn't exist
|
||||
bals = append(bals, nil)
|
||||
}
|
||||
if bytes > softResponseLimit {
|
||||
if bytes > req.Bytes {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ type TrieNodesPacket struct {
|
|||
type GetAccessListsPacket struct {
|
||||
ID uint64 // Request ID to match up responses with
|
||||
Hashes []common.Hash // Block hashes to retrieve BALs for
|
||||
Bytes uint64 // Soft limit at which to stop returning data
|
||||
}
|
||||
|
||||
// AccessListsPacket is the response to GetAccessListsPacket.
|
||||
|
|
|
|||
Loading…
Reference in a new issue