Skip to content

Commit

Permalink
feat: add first block param
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Aug 6, 2024
1 parent 67e52d8 commit 8f2306f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/app_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (a *AppManager) ProcessSnapshot(block *types.Block) {

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

neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight())
neededBlocks := utils.MinInt64(a.Config.BlocksWindow, a.StateManager.GetLastBlockHeight()-a.Config.FirstBlock)

Check warning on line 217 in pkg/app_manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/app_manager.go#L217

Added line #L217 was not covered by tests
hasEnoughBlocks := blocksCount >= neededBlocks

if !hasEnoughBlocks {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ChainConfig struct {
BlocksWindow int64 `default:"10000" toml:"blocks-window"`
MinSignedPerWindow float64 `default:"0.05" toml:"min-signed-per-window"`
SnapshotsInterval int64 `default:"1" toml:"snapshots-interval"`
FirstBlock int64 `default:"0" toml:"first-block"`
Pagination ChainPagination `toml:"pagination"`
Intervals IntervalsConfig `toml:"intervals"`

Expand Down
4 changes: 2 additions & 2 deletions pkg/state/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (m *Manager) GetSnapshot() (snapshotPkg.Snapshot, error) {
validators := m.state.GetValidators()
entries := make(types.Entries, len(validators))

neededBlocks := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight())
neededBlocks := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()-m.config.FirstBlock)

Check warning on line 143 in pkg/state/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/state/manager.go#L143

Added line #L143 was not covered by tests

for _, validator := range validators {
// Taking the active status from the last block, as there might be a case
Expand Down Expand Up @@ -238,7 +238,7 @@ func (m *Manager) GetBlockTime() time.Duration {
}

func (m *Manager) GetValidatorMissedBlocks(validator *types.Validator) (types.SignatureInto, error) {
blocksToCheck := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight())
blocksToCheck := utils.MinInt64(m.config.BlocksWindow, m.GetLastBlockHeight()-m.config.FirstBlock)

Check warning on line 241 in pkg/state/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/state/manager.go#L241

Added line #L241 was not covered by tests
return m.state.GetValidatorMissedBlocks(validator, blocksToCheck)
}

Expand Down

0 comments on commit 8f2306f

Please sign in to comment.