From bbedddb7d523a9eec5d02e5425d245d9807e8791 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 18 Mar 2025 21:16:40 +0100 Subject: [PATCH] core/rawdb: log tx index pruning progress --- core/rawdb/chain_iterator.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/rawdb/chain_iterator.go b/core/rawdb/chain_iterator.go index 64d252f31b..cc6350f242 100644 --- a/core/rawdb/chain_iterator.go +++ b/core/rawdb/chain_iterator.go @@ -377,9 +377,14 @@ func PruneTransactionIndex(db ethdb.Database, pruneBlock uint64) { // There are transactions below pruneBlock in the index. Iterate the entire index to // remove the entries. Note if this fails, the index is messed up, but tail still // points to the old tail. - iter := db.NewIterator(txLookupPrefix, nil) + var ( + iter = db.NewIterator(txLookupPrefix, nil) + count int + removed int + ) defer iter.Release() for iter.Next() { + count++ v := iter.Value() if len(v) > 8 { log.Error("Skipping prune legacy tx index entry", "hash", fmt.Sprintf("%x", iter.Key())) @@ -390,8 +395,16 @@ func PruneTransactionIndex(db ethdb.Database, pruneBlock uint64) { if err := db.Delete(iter.Key()); err != nil { log.Crit("Error deleting tx lookup entry", "hash", fmt.Sprintf("%x", iter.Key())) } + removed++ + } + if count%10000 == 0 { + log.Info("Pruning tx index", "count", count, "removed", removed) } } + if iter.Error() != nil { + log.Error("Tx index pruning iterator error", "err", iter.Error()) + } + WriteTxIndexTail(db, pruneBlock) }