mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/types: optimize EncodeBlockReceiptLists
This commit is contained in:
parent
76b546c15b
commit
dd575769df
1 changed files with 7 additions and 6 deletions
|
|
@ -380,17 +380,18 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
|
||||||
|
|
||||||
// EncodeBlockReceiptLists encodes a list of block receipt lists into RLP.
|
// EncodeBlockReceiptLists encodes a list of block receipt lists into RLP.
|
||||||
func EncodeBlockReceiptLists(receipts []Receipts) []rlp.RawValue {
|
func EncodeBlockReceiptLists(receipts []Receipts) []rlp.RawValue {
|
||||||
result := make([]rlp.RawValue, 0)
|
var storageReceipts []*ReceiptForStorage
|
||||||
for _, receipt := range receipts {
|
result := make([]rlp.RawValue, len(receipts))
|
||||||
storageReceipts := make([]*ReceiptForStorage, len(receipt))
|
for i, receipt := range receipts {
|
||||||
for i, r := range receipt {
|
storageReceipts = storageReceipts[:0]
|
||||||
storageReceipts[i] = (*ReceiptForStorage)(r)
|
for _, r := range receipt {
|
||||||
|
storageReceipts = append(storageReceipts, (*ReceiptForStorage)(r))
|
||||||
}
|
}
|
||||||
bytes, err := rlp.EncodeToBytes(storageReceipts)
|
bytes, err := rlp.EncodeToBytes(storageReceipts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to encode block receipts", "err", err)
|
log.Crit("Failed to encode block receipts", "err", err)
|
||||||
}
|
}
|
||||||
result = append(result, bytes)
|
result[i] = bytes
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue