mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-16 20:01:37 +00:00
avoid decoding during validation
This commit is contained in:
parent
be6aa56569
commit
48da785c86
1 changed files with 15 additions and 7 deletions
|
|
@ -525,13 +525,21 @@ func (p *Peer) validateLastBlockReceipt(receiptLists []*ReceiptList69, id uint64
|
||||||
// should be dropped, don't clear the buffer
|
// should be dropped, don't clear the buffer
|
||||||
return 0, fmt.Errorf("total number of tx exceeded limit")
|
return 0, fmt.Errorf("total number of tx exceeded limit")
|
||||||
}
|
}
|
||||||
// todo: avoid calling Items() here
|
// Count log size per receipt
|
||||||
receipts, err := lastReceipts.items.Items()
|
it := lastReceipts.items.ContentIterator()
|
||||||
if err != nil {
|
for it.Next() {
|
||||||
return 0, fmt.Errorf("invalid receipts: %v", err)
|
content, _, err := rlp.SplitList(it.Value())
|
||||||
}
|
if err != nil {
|
||||||
for _, rc := range receipts {
|
return 0, fmt.Errorf("invalid receipt structure: %v", err)
|
||||||
log += uint64(len(rc.Logs))
|
}
|
||||||
|
rest := content
|
||||||
|
for range 3 {
|
||||||
|
_, _, rest, err = rlp.Split(rest)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("invalid receipt structure: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log += uint64(len(rest))
|
||||||
}
|
}
|
||||||
// Verify that the overall downloaded receipt size does not exceed the block gas limit.
|
// Verify that the overall downloaded receipt size does not exceed the block gas limit.
|
||||||
if previousLog+log > gasUsed/params.LogDataGas {
|
if previousLog+log > gasUsed/params.LogDataGas {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue