core/rawdb: remove unused deriveLogFields (#29913)
Co-authored-by: Gary Rong <garyrong0905@gmail.com> Co-authored-by: Martin HS <martin@swende.se>
This commit is contained in:
parent
e85e21c932
commit
d09ddac399
@ -19,7 +19,6 @@ package rawdb
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"slices"
|
"slices"
|
||||||
@ -695,27 +694,6 @@ func (r *receiptLogs) DecodeRLP(s *rlp.Stream) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// deriveLogFields fills the logs in receiptLogs with information such as block number, txhash, etc.
|
|
||||||
func deriveLogFields(receipts []*receiptLogs, hash common.Hash, number uint64, txs types.Transactions) error {
|
|
||||||
logIndex := uint(0)
|
|
||||||
if len(txs) != len(receipts) {
|
|
||||||
return errors.New("transaction and receipt count mismatch")
|
|
||||||
}
|
|
||||||
for i := 0; i < len(receipts); i++ {
|
|
||||||
txHash := txs[i].Hash()
|
|
||||||
// The derived log fields can simply be set from the block and transaction
|
|
||||||
for j := 0; j < len(receipts[i].Logs); j++ {
|
|
||||||
receipts[i].Logs[j].BlockNumber = number
|
|
||||||
receipts[i].Logs[j].BlockHash = hash
|
|
||||||
receipts[i].Logs[j].TxHash = txHash
|
|
||||||
receipts[i].Logs[j].TxIndex = uint(i)
|
|
||||||
receipts[i].Logs[j].Index = logIndex
|
|
||||||
logIndex++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReadLogs retrieves the logs for all transactions in a block. In case
|
// ReadLogs retrieves the logs for all transactions in a block. In case
|
||||||
// receipts is not found, a nil is returned.
|
// receipts is not found, a nil is returned.
|
||||||
// Note: ReadLogs does not derive unstored log fields.
|
// Note: ReadLogs does not derive unstored log fields.
|
||||||
|
@ -794,7 +794,7 @@ func TestDeriveLogFields(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
// Create the corresponding receipts
|
// Create the corresponding receipts
|
||||||
receipts := []*receiptLogs{
|
receipts := []*types.Receipt{
|
||||||
{
|
{
|
||||||
Logs: []*types.Log{
|
Logs: []*types.Log{
|
||||||
{Address: common.BytesToAddress([]byte{0x11})},
|
{Address: common.BytesToAddress([]byte{0x11})},
|
||||||
@ -818,9 +818,7 @@ func TestDeriveLogFields(t *testing.T) {
|
|||||||
// Derive log metadata fields
|
// Derive log metadata fields
|
||||||
number := big.NewInt(1)
|
number := big.NewInt(1)
|
||||||
hash := common.BytesToHash([]byte{0x03, 0x14})
|
hash := common.BytesToHash([]byte{0x03, 0x14})
|
||||||
if err := deriveLogFields(receipts, hash, number.Uint64(), txs); err != nil {
|
types.Receipts(receipts).DeriveFields(params.TestChainConfig, hash, number.Uint64(), 0, big.NewInt(0), big.NewInt(0), txs)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over all the computed fields and check that they're correct
|
// Iterate over all the computed fields and check that they're correct
|
||||||
logIndex := uint(0)
|
logIndex := uint(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user