From e53a7df91608f7cc2cbdf67b533df7a5545dc78b Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Fri, 6 Jan 2023 16:00:17 +0000 Subject: [PATCH] Rename `StoreJournalRecord` to `RecordAndPrune` --- dot/state/interfaces.go | 2 +- dot/state/storage.go | 2 +- internal/pruner/archive/pruner.go | 4 ++-- internal/pruner/full/pruner.go | 6 +++--- internal/pruner/full/pruner_test.go | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dot/state/interfaces.go b/dot/state/interfaces.go index fe8338dbae9..77a2d8e3f66 100644 --- a/dot/state/interfaces.go +++ b/dot/state/interfaces.go @@ -106,6 +106,6 @@ type Telemetry interface { // Pruner tracks state deltas and prunes keys from the storage database. type Pruner interface { - StoreJournalRecord(deletedNodeHashes, insertedNodeHashes map[common.Hash]struct{}, + RecordAndPrune(deletedNodeHashes, insertedNodeHashes map[common.Hash]struct{}, blockHash common.Hash, blockNumber uint32) error } diff --git a/dot/state/storage.go b/dot/state/storage.go index 46d6df0af47..6b08e9a52a2 100644 --- a/dot/state/storage.go +++ b/dot/state/storage.go @@ -88,7 +88,7 @@ func (s *StorageState) StoreTrie(ts *rtstorage.TrieState, header *types.Header) deletedNodeHashes[nodeHash] = struct{}{} } - err = s.pruner.StoreJournalRecord(deletedNodeHashes, insertedNodeHashes, header.Hash(), uint32(header.Number)) + err = s.pruner.RecordAndPrune(deletedNodeHashes, insertedNodeHashes, header.Hash(), uint32(header.Number)) if err != nil { return err } diff --git a/internal/pruner/archive/pruner.go b/internal/pruner/archive/pruner.go index 2d2fe4836b4..05c06be63a8 100644 --- a/internal/pruner/archive/pruner.go +++ b/internal/pruner/archive/pruner.go @@ -13,7 +13,7 @@ func New() *Pruner { return &Pruner{} } -// StoreJournalRecord for archive node doesn't do anything. -func (*Pruner) StoreJournalRecord(_, _ map[common.Hash]struct{}, _ common.Hash, _ uint32) (_ error) { +// RecordAndPrune for archive node doesn't do anything. +func (*Pruner) RecordAndPrune(_, _ map[common.Hash]struct{}, _ common.Hash, _ uint32) (_ error) { return nil } diff --git a/internal/pruner/full/pruner.go b/internal/pruner/full/pruner.go index f3fb896db14..1a9d4bfdc5a 100644 --- a/internal/pruner/full/pruner.go +++ b/internal/pruner/full/pruner.go @@ -33,7 +33,7 @@ type Pruner struct { // highestBlockNumber is the highest block number stored in the journal. // It is updated on disk but cached in memory as this field. highestBlockNumber uint32 - // mutex protects the in memory data members since StoreJournalRecord + // mutex protects the in memory data members since RecordAndPrune // is called in lib/babe `epochHandler`'s `run` method which is run // in its own goroutine. mutex sync.RWMutex @@ -87,10 +87,10 @@ func New(journalDB JournalDatabase, storageDB ChainDBNewBatcher, retainBlocks ui return pruner, nil } -// StoreJournalRecord stores the trie deltas impacting the storage database for a particular +// RecordAndPrune stores the trie deltas impacting the storage database for a particular // block hash. It prunes all block numbers falling off the window of block numbers to keep, // before inserting the new record. It is thread safe to call. -func (p *Pruner) StoreJournalRecord(deletedNodeHashes, insertedNodeHashes map[common.Hash]struct{}, +func (p *Pruner) RecordAndPrune(deletedNodeHashes, insertedNodeHashes map[common.Hash]struct{}, blockHash common.Hash, blockNumber uint32) (err error) { p.mutex.Lock() defer p.mutex.Unlock() diff --git a/internal/pruner/full/pruner_test.go b/internal/pruner/full/pruner_test.go index f874a5ca399..0f1e1a87a0b 100644 --- a/internal/pruner/full/pruner_test.go +++ b/internal/pruner/full/pruner_test.go @@ -38,7 +38,7 @@ func Test_Pruner(t *testing.T) { setNodeHashesInStorageDB(t, storageDB, []common.Hash{{1}, {2}}) logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", uint32(0), "0x64000000...00000000") - err = pruner.StoreJournalRecord( + err = pruner.RecordAndPrune( map[common.Hash]struct{}{}, // first block has no deleted node hashes map[common.Hash]struct{}{{1}: {}, {2}: {}}, // inserted node hashes common.Hash{100}, // block hash @@ -57,7 +57,7 @@ func Test_Pruner(t *testing.T) { setNodeHashesInStorageDB(t, storageDB, []common.Hash{{3}, {4}}) logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", uint32(1), "0x65000000...00000000") - err = pruner.StoreJournalRecord( + err = pruner.RecordAndPrune( map[common.Hash]struct{}{{1}: {}}, // deleted node hashes map[common.Hash]struct{}{{3}: {}, {4}: {}}, // inserted node hashes common.Hash{101}, // block hash @@ -83,7 +83,7 @@ func Test_Pruner(t *testing.T) { setNodeHashesInStorageDB(t, storageDB, []common.Hash{{5}, {6}}) logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", uint32(1), "0x66000000...00000000") - err = pruner.StoreJournalRecord( + err = pruner.RecordAndPrune( map[common.Hash]struct{}{{3}: {}}, // deleted node hashes map[common.Hash]struct{}{{5}: {}, {6}: {}}, // inserted node hashes common.Hash{102}, // block hash @@ -115,7 +115,7 @@ func Test_Pruner(t *testing.T) { logger.EXPECT().Debugf("pruned block numbers [%d..%d]", uint32(0), uint32(0)) logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", uint32(2), "0x67000000...00000000") - err = pruner.StoreJournalRecord( + err = pruner.RecordAndPrune( map[common.Hash]struct{}{{5}: {}}, // deleted node hashes map[common.Hash]struct{}{{7}: {}, {8}: {}}, // inserted node hashes common.Hash{103}, // block hash @@ -152,7 +152,7 @@ func Test_Pruner(t *testing.T) { logger.EXPECT().Debugf("pruned block numbers [%d..%d]", uint32(1), uint32(1)) logger.EXPECT().Debugf("journal data stored for block number %d and block hash %s", uint32(3), "0x68000000...00000000") - err = pruner.StoreJournalRecord( + err = pruner.RecordAndPrune( map[common.Hash]struct{}{{7}: {}}, // deleted node hashes map[common.Hash]struct{}{{9}: {}, {10}: {}}, // inserted node hashes common.Hash{104}, // block hash