Skip to content

Commit

Permalink
Call observer only when retain height changes (cometbft#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalicevic committed Jan 24, 2024
1 parent d736369 commit ad5bff2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions state/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ func (p *Pruner) pruneABCIResponses() {
return
default:
newRetainHeight := p.pruneABCIResToRetainHeight(lastRetainHeight)
p.observer.PrunerPrunedABCIRes(&ABCIResponsesPrunedInfo{
FromHeight: lastRetainHeight,
ToHeight: newRetainHeight - 1,
})
if newRetainHeight != lastRetainHeight {
p.observer.PrunerPrunedABCIRes(&ABCIResponsesPrunedInfo{
FromHeight: lastRetainHeight,
ToHeight: newRetainHeight - 1,
})
}
lastRetainHeight = newRetainHeight
time.Sleep(p.interval)
}
Expand All @@ -256,10 +258,12 @@ func (p *Pruner) pruneBlocks() {
return
default:
newRetainHeight := p.pruneBlocksToRetainHeight(lastRetainHeight)
p.observer.PrunerPrunedBlocks(&BlocksPrunedInfo{
FromHeight: lastRetainHeight,
ToHeight: newRetainHeight - 1,
})
if newRetainHeight != lastRetainHeight {
p.observer.PrunerPrunedBlocks(&BlocksPrunedInfo{
FromHeight: lastRetainHeight,
ToHeight: newRetainHeight - 1,
})
}
lastRetainHeight = newRetainHeight
time.Sleep(p.interval)
}
Expand Down

0 comments on commit ad5bff2

Please sign in to comment.