mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/rawdb: tiny review nit fixes
This commit is contained in:
parent
835abc4e7f
commit
7be6104114
2 changed files with 6 additions and 9 deletions
|
|
@ -34,18 +34,16 @@ func ReadTxLookupEntry(db ethdb.Reader, hash common.Hash) *uint64 {
|
|||
if len(data) == 0 {
|
||||
return nil
|
||||
}
|
||||
//
|
||||
// Database v6 tx lookup just stores the block number
|
||||
if len(data) < common.HashLength {
|
||||
var number big.Int
|
||||
number.SetBytes(data)
|
||||
numberU64 := number.Uint64()
|
||||
return &numberU64
|
||||
number := new(big.Int).SetBytes(data).Uint64()
|
||||
return &number
|
||||
}
|
||||
// Database v4 tx lookup format just stores the hash.
|
||||
// Database v4-v5 tx lookup format just stores the hash
|
||||
if len(data) == common.HashLength {
|
||||
return ReadHeaderNumber(db, common.BytesToHash(data))
|
||||
}
|
||||
// Finally try database v3 tx lookup format.
|
||||
// Finally try database v3 tx lookup format
|
||||
var entry LegacyTxLookupEntry
|
||||
if err := rlp.DecodeBytes(data, &entry); err != nil {
|
||||
log.Error("Invalid transaction lookup entry RLP", "hash", hash, "blob", data, "err", err)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func TestLookupStorage(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
"DatabaseV4",
|
||||
"DatabaseV4-V5",
|
||||
func(db ethdb.Writer, block *types.Block) {
|
||||
for _, tx := range block.Transactions() {
|
||||
db.Put(txLookupKey(tx.Hash()), block.Hash().Bytes())
|
||||
|
|
@ -64,7 +64,6 @@ func TestLookupStorage(t *testing.T) {
|
|||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
db := NewMemoryDatabase()
|
||||
|
||||
tx1 := types.NewTransaction(1, common.BytesToAddress([]byte{0x11}), big.NewInt(111), 1111, big.NewInt(11111), []byte{0x11, 0x11, 0x11})
|
||||
|
|
|
|||
Loading…
Reference in a new issue