Skip to content

Commit 98402f9

Browse files
9547rjl493456442holiman
authored andcommitted
core/rawdb: remove unused deriveLogFields (ethereum#29913)
Co-authored-by: Gary Rong <[email protected]> Co-authored-by: Martin HS <[email protected]>
1 parent a5877ec commit 98402f9

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

core/rawdb/accessors_chain.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package rawdb
1919
import (
2020
"bytes"
2121
"encoding/binary"
22-
"errors"
2322
"fmt"
2423
"math/big"
2524
"slices"
@@ -695,27 +694,6 @@ func (r *receiptLogs) DecodeRLP(s *rlp.Stream) error {
695694
return nil
696695
}
697696

698-
// deriveLogFields fills the logs in receiptLogs with information such as block number, txhash, etc.
699-
func deriveLogFields(receipts []*receiptLogs, hash common.Hash, number uint64, txs types.Transactions) error {
700-
logIndex := uint(0)
701-
if len(txs) != len(receipts) {
702-
return errors.New("transaction and receipt count mismatch")
703-
}
704-
for i := 0; i < len(receipts); i++ {
705-
txHash := txs[i].Hash()
706-
// The derived log fields can simply be set from the block and transaction
707-
for j := 0; j < len(receipts[i].Logs); j++ {
708-
receipts[i].Logs[j].BlockNumber = number
709-
receipts[i].Logs[j].BlockHash = hash
710-
receipts[i].Logs[j].TxHash = txHash
711-
receipts[i].Logs[j].TxIndex = uint(i)
712-
receipts[i].Logs[j].Index = logIndex
713-
logIndex++
714-
}
715-
}
716-
return nil
717-
}
718-
719697
// ReadLogs retrieves the logs for all transactions in a block. In case
720698
// receipts is not found, a nil is returned.
721699
// Note: ReadLogs does not derive unstored log fields.

core/rawdb/accessors_chain_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ func TestDeriveLogFields(t *testing.T) {
794794
}),
795795
}
796796
// Create the corresponding receipts
797-
receipts := []*receiptLogs{
797+
receipts := []*types.Receipt{
798798
{
799799
Logs: []*types.Log{
800800
{Address: common.BytesToAddress([]byte{0x11})},
@@ -818,9 +818,7 @@ func TestDeriveLogFields(t *testing.T) {
818818
// Derive log metadata fields
819819
number := big.NewInt(1)
820820
hash := common.BytesToHash([]byte{0x03, 0x14})
821-
if err := deriveLogFields(receipts, hash, number.Uint64(), txs); err != nil {
822-
t.Fatal(err)
823-
}
821+
types.Receipts(receipts).DeriveFields(params.TestChainConfig, hash, number.Uint64(), 0, big.NewInt(0), big.NewInt(0), txs)
824822

825823
// Iterate over all the computed fields and check that they're correct
826824
logIndex := uint(0)

0 commit comments

Comments
 (0)