mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Update accessors_indexes.go
This commit is contained in:
parent
7623170f6a
commit
3bd0deacbc
1 changed files with 11 additions and 13 deletions
|
|
@ -154,28 +154,26 @@ func ReadTransaction(db ethdb.Reader, hash common.Hash) (*types.Transaction, com
|
||||||
return nil, common.Hash{}, 0, 0
|
return nil, common.Hash{}, 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
txIndex := 0
|
txIndex := uint64(0)
|
||||||
for txnIterator.Next() && txnIterator.Err() == nil {
|
for txnIterator.Next() && txnIterator.Err() == nil {
|
||||||
txnRLP := txnIterator.Value()
|
// The preimage for the hash calculation of legacy transactions
|
||||||
|
// is just their RLP encoding. For typed (EIP-2718) transactions,
|
||||||
// Preimage for hash calculation of legacy transactions
|
// which are encoded as byte arrays, the preimage is the content of
|
||||||
// are just their RLP encoding, but for EIP-2728 transactions
|
// the byte array, so trim their prefix here.
|
||||||
// the prefix needs to be trimmed before hashing.
|
txRLP := txnIterator.Value()
|
||||||
rlpKind, hashPreimage, _, err := rlp.Split(txnRLP)
|
rlpKind, txHashPayload, _, err := rlp.Split(txRLP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, common.Hash{}, 0, 0
|
return nil, common.Hash{}, 0, 0
|
||||||
}
|
}
|
||||||
// Legacy transactions are encoded as rlp lists.
|
|
||||||
if rlpKind == rlp.List {
|
if rlpKind == rlp.List {
|
||||||
hashPreimage = txnRLP
|
txHashPayload = txRLP
|
||||||
}
|
}
|
||||||
|
if crypto.Keccak256Hash(txHashPayload) == hash {
|
||||||
if crypto.Keccak256Hash(hashPreimage) == hash {
|
|
||||||
var tx types.Transaction
|
var tx types.Transaction
|
||||||
if err := rlp.DecodeBytes(txnRLP, &tx); err != nil {
|
if err := rlp.DecodeBytes(txRLP, &tx); err != nil {
|
||||||
return nil, common.Hash{}, 0, 0
|
return nil, common.Hash{}, 0, 0
|
||||||
}
|
}
|
||||||
return &tx, blockHash, *blockNumber, uint64(txIndex)
|
return &tx, blockHash, *blockNumber, txIndex
|
||||||
}
|
}
|
||||||
txIndex++
|
txIndex++
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue