Skip to content

Commit

Permalink
Refactor: addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hmoog committed Nov 7, 2023
1 parent 7b13130 commit 40a94e7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/protocol/engine/eviction/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,18 @@ func (s *State) PopulateFromStorage(latestCommitmentSlot iotago.SlotIndex) {
}

func (s *State) Reset() {
rootBlocksToClear := make([]iotago.BlockID, 0)
s.evictionMutex.Lock()
defer s.evictionMutex.Unlock()

s.rootBlocks.ForEach(func(slot iotago.SlotIndex, storage *shrinkingmap.ShrinkingMap[iotago.BlockID, iotago.CommitmentID]) {
if slot > s.lastEvictedSlot {
storage.ForEach(func(blockID iotago.BlockID, commitmentID iotago.CommitmentID) bool {
rootBlocksToClear = append(rootBlocksToClear, blockID)
s.RemoveRootBlock(blockID)

return true
})
}
})

for _, blockID := range rootBlocksToClear {
s.RemoveRootBlock(blockID)
}
}

// latestNonEmptySlot returns the latest slot that contains a rootblock.
Expand Down

0 comments on commit 40a94e7

Please sign in to comment.