mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 12:21:38 +00:00
fix: fix trimReceiptsRLP bug
This commit is contained in:
parent
b35f62794f
commit
74dd001911
1 changed files with 4 additions and 4 deletions
|
|
@ -388,9 +388,9 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstBlockReceiptIndex > 0 && lookups == 0 {
|
if firstBlockReceiptIndex > 0 && lookups == 0 {
|
||||||
results, lastBlockIncomplete = trimReceiptsRLP(results, int(firstBlockReceiptIndex))
|
results, lastBlockIncomplete = trimReceiptsRLP(results, int(firstBlockReceiptIndex), maxPacketSize)
|
||||||
} else if bytes+len(results) > maxPacketSize {
|
} else if bytes+len(results) > maxPacketSize {
|
||||||
results, lastBlockIncomplete = trimReceiptsRLP(results, 0)
|
results, lastBlockIncomplete = trimReceiptsRLP(results, 0, maxPacketSize-bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
receipts = append(receipts, results)
|
receipts = append(receipts, results)
|
||||||
|
|
@ -401,7 +401,7 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
// trimReceiptsRLP trims raw value from `from` index until it exceeds limit
|
// trimReceiptsRLP trims raw value from `from` index until it exceeds limit
|
||||||
func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int) (rlp.RawValue, bool) {
|
func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int, limit int) (rlp.RawValue, bool) {
|
||||||
var (
|
var (
|
||||||
out bytes.Buffer
|
out bytes.Buffer
|
||||||
buffer = rlp.NewEncoderBuffer(&out)
|
buffer = rlp.NewEncoderBuffer(&out)
|
||||||
|
|
@ -418,7 +418,7 @@ func trimReceiptsRLP(receiptsRLP rlp.RawValue, from int) (rlp.RawValue, bool) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
receipt := iter.Value()
|
receipt := iter.Value()
|
||||||
if bytes+len(receipt) > maxPacketSize {
|
if bytes+len(receipt) > limit {
|
||||||
overflow = true
|
overflow = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue