core/rawdb: single point of maintenance for writing and deleting tx lookup indexes (#21480)

This commit is contained in:
Giuseppe Bertone
2020-09-15 10:37:01 +02:00
committed by GitHub
parent 4764b2f0be
commit 0185ee0993
5 changed files with 31 additions and 29 deletions

View File

@@ -57,13 +57,13 @@ func (h *testHasher) Hash() common.Hash {
// Tests that positional lookup metadata can be stored and retrieved.
func TestLookupStorage(t *testing.T) {
tests := []struct {
name string
writeTxLookupEntries func(ethdb.Writer, *types.Block)
name string
writeTxLookupEntriesByBlock func(ethdb.Writer, *types.Block)
}{
{
"DatabaseV6",
func(db ethdb.Writer, block *types.Block) {
WriteTxLookupEntries(db, block)
WriteTxLookupEntriesByBlock(db, block)
},
},
{
@@ -110,7 +110,7 @@ func TestLookupStorage(t *testing.T) {
// Insert all the transactions into the database, and verify contents
WriteCanonicalHash(db, block.Hash(), block.NumberU64())
WriteBlock(db, block)
tc.writeTxLookupEntries(db, block)
tc.writeTxLookupEntriesByBlock(db, block)
for i, tx := range txs {
if txn, hash, number, index := ReadTransaction(db, tx.Hash()); txn == nil {