Skip to content

Commit

Permalink
comments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Mar 22, 2024
1 parent e658007 commit 6ac8d93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion consensus/polybft/state_store_epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *EpochStore) getNearestOrEpochSnapshot(epoch uint64, dbTx *bolt.Tx) (*va
)

getFn := func(tx *bolt.Tx) error {
for ; epoch >= 0; epoch-- {
for {
v := tx.Bucket(validatorSnapshotsBucket).Get(common.EncodeUint64ToBytes(epoch))
if v != nil {
return json.Unmarshal(v, &snapshot)
Expand All @@ -110,6 +110,8 @@ func (s *EpochStore) getNearestOrEpochSnapshot(epoch uint64, dbTx *bolt.Tx) (*va
if epoch == 0 { // prevent uint64 underflow
break
}

epoch--
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion consensus/polybft/validators_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (v *validatorsSnapshotCache) getLastCachedSnapshot(currentEpoch uint64,
}

// if we do not have a snapshot in memory for given epoch, we will get the latest one we have
for ; currentEpoch >= 0; currentEpoch-- {
for {
cachedSnapshot = v.snapshots[currentEpoch]
if cachedSnapshot != nil {
v.logger.Trace("Found snapshot in memory cache", "Epoch", currentEpoch)
Expand All @@ -308,6 +308,8 @@ func (v *validatorsSnapshotCache) getLastCachedSnapshot(currentEpoch uint64,
if currentEpoch == 0 { // prevent uint64 underflow
break
}

currentEpoch--
}

dbSnapshot, err := v.state.EpochStore.getNearestOrEpochSnapshot(epochToQuery, dbTx)
Expand Down

0 comments on commit 6ac8d93

Please sign in to comment.