Skip to content

Commit

Permalink
fix: respect first block in count x4
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Aug 7, 2024
1 parent 29d0254 commit ba6ccaa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/app_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ func (a *AppManager) ProcessSnapshot(block *types.Block) {
}
}

totalBlocksCount := a.StateManager.GetBlocksCountSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock - 1)
totalBlocksCount := a.StateManager.GetBlocksCountSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock + 1)
a.Logger.Info().
Int64("count", totalBlocksCount).
Int64("height", block.Height).
Msg("Added new Tendermint block into state")

blocksCount := a.StateManager.GetBlocksCountSinceLatest(a.Config.BlocksWindow)

neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight()-a.Config.FirstBlock-1)
neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight()-a.Config.FirstBlock+1)
hasEnoughBlocks := blocksCount >= neededBlocks

if !hasEnoughBlocks {
Expand Down Expand Up @@ -405,10 +405,10 @@ func (a *AppManager) PopulateBlocks() {
return
}

missingBlocks := a.StateManager.GetMissingBlocksSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock - 1)
missingBlocks := a.StateManager.GetMissingBlocksSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock + 1)
if len(missingBlocks) == 0 {
a.Logger.Info().
Int64("count", a.Config.StoreBlocks-a.Config.FirstBlock-1).
Int64("count", a.Config.StoreBlocks-a.Config.FirstBlock+1).
Msg("Got enough blocks for populating")
a.IsPopulatingBlocks = false
return
Expand All @@ -417,7 +417,7 @@ func (a *AppManager) PopulateBlocks() {
blocksChunks := utils.SplitIntoChunks(missingBlocks, a.Config.Pagination.BlocksSearch)

for _, chunk := range blocksChunks {
count := a.StateManager.GetBlocksCountSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock - 1)
count := a.StateManager.GetBlocksCountSinceLatest(a.Config.StoreBlocks - a.Config.FirstBlock + 1)

a.Logger.Info().
Int64("count", count).
Expand Down

0 comments on commit ba6ccaa

Please sign in to comment.