From 34ea4c393d3eda01b43fbc7dc727241550252cc3 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sun, 6 Aug 2023 13:30:20 +0800 Subject: [PATCH] cleanup --- indexer/database/file/indexer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/indexer/database/file/indexer.go b/indexer/database/file/indexer.go index 85d6958..8d229fd 100644 --- a/indexer/database/file/indexer.go +++ b/indexer/database/file/indexer.go @@ -57,7 +57,7 @@ type StateDiffIndexer struct { chainConfig *params.ChainConfig nodeID string wg *sync.WaitGroup - removedCacheFlag *uint32 + removedCacheFlag uint32 } // NewStateDiffIndexer creates a void implementation of interfaces.StateDiffIndexer @@ -130,7 +130,6 @@ func (sdi *StateDiffIndexer) ReportDBMetrics(time.Duration, <-chan bool) {} // PushBlock pushes and indexes block data in sql, except state & storage nodes (includes header, uncles, transactions & receipts) // Returns an initiated DB transaction which must be Closed via defer to commit or rollback func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receipts, totalDifficulty *big.Int) (interfaces.Batch, error) { - sdi.removedCacheFlag = new(uint32) start, t := time.Now(), time.Now() blockHash := block.Hash() blockHashStr := blockHash.String() @@ -388,8 +387,8 @@ func (sdi *StateDiffIndexer) PushStateNode(batch interfaces.Batch, stateNode sdt // publish the state node var stateModel models.StateNodeModel if stateNode.Removed { - if atomic.LoadUint32(sdi.removedCacheFlag) == 0 { - atomic.StoreUint32(sdi.removedCacheFlag, 1) + if atomic.LoadUint32(&sdi.removedCacheFlag) == 0 { + atomic.StoreUint32(&sdi.removedCacheFlag, 1) sdi.fileWriter.upsertIPLDDirect(tx.BlockNumber, shared.RemovedNodeStateCID, []byte{}) } stateModel = models.StateNodeModel{ @@ -419,8 +418,8 @@ func (sdi *StateDiffIndexer) PushStateNode(batch interfaces.Batch, stateNode sdt // if there are any storage nodes associated with this node, publish and index them for _, storageNode := range stateNode.StorageDiff { if storageNode.Removed { - if atomic.LoadUint32(sdi.removedCacheFlag) == 0 { - atomic.StoreUint32(sdi.removedCacheFlag, 1) + if atomic.LoadUint32(&sdi.removedCacheFlag) == 0 { + atomic.StoreUint32(&sdi.removedCacheFlag, 1) sdi.fileWriter.upsertIPLDDirect(tx.BlockNumber, shared.RemovedNodeStorageCID, []byte{}) } storageModel := models.StorageNodeModel{