Skip to content

Commit

Permalink
fix rolling out cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
ciripel committed Jun 18, 2024
1 parent 43e9934 commit 642aa9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ func (e *Engine) fetchAutomatically(config *configuration.Runtime) {
}

for cycle := e.state.lastOnChainCompletedCycle + 1; cycle <= lastCompletedCycle; cycle++ {
if err := e.FetchCycleDelegationStates(e.ctx, cycle, nil); err != nil {
if err = e.FetchCycleDelegationStates(e.ctx, cycle, nil); err != nil {
e.logger.Error("failed to fetch cycle delegation states", "cycle", cycle, "error", err.Error())
}
e.store.PruneDelegationState(cycle, config)
if err = e.store.PruneDelegationState(cycle, config); err != nil {
e.logger.Error("failed to prune cycles out", "error", err.Error())
}
}

e.state.SetLastOnChainCompletedCycle(lastCompletedCycle)
Expand Down
2 changes: 1 addition & 1 deletion store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *Store) PruneDelegationState(cycle int64, config *configuration.Runtime)
}

prunedCycle := cycle - int64(config.Storage.StoredCycles)
state := &StoredDelegationState{Cycle: prunedCycle}
state := &StoredDelegationState{}
slog.Debug("pruning delegation states smaller than", "cycle", prunedCycle)
return s.db.Model(&StoredDelegationState{}).Where("cycle < ?", prunedCycle).Delete(state).Error

Expand Down

0 comments on commit 642aa9a

Please sign in to comment.