Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bao1029p committed Nov 1, 2023
1 parent 531b896 commit f596671
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions x/blobstream/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,16 @@ func pruneAttestations(ctx sdk.Context, k keeper.Keeper) {
if !k.CheckLatestAttestationNonce(ctx) {
return
}
found := k.CheckEarliestAvailableAttestationNonce(ctx)
if !found {
if !k.CheckEarliestAvailableAttestationNonce(ctx) {
ctx.Logger().Error("couldn't find earliest attestation for pruning")
return
}

currentBlockTime := ctx.BlockTime()
latestAttestationNonce := k.GetLatestAttestationNonce(ctx)
earliestNounce := k.GetEarliestAvailableAttestationNonce(ctx)
earliestNonce := k.GetEarliestAvailableAttestationNonce(ctx)
var newEarliestAvailableNonce uint64
for newEarliestAvailableNonce = earliestNounce; newEarliestAvailableNonce < latestAttestationNonce; newEarliestAvailableNonce++ {
for newEarliestAvailableNonce = earliestNonce; newEarliestAvailableNonce < latestAttestationNonce; newEarliestAvailableNonce++ {
newEarliestAttestation, found, err := k.GetAttestationByNonce(ctx, newEarliestAvailableNonce)
if err != nil {
ctx.Logger().Error("error getting attestation for pruning", "nonce", newEarliestAvailableNonce, "err", err.Error())
Expand All @@ -175,13 +174,13 @@ func pruneAttestations(ctx sdk.Context, k keeper.Keeper) {
}
k.DeleteAttestation(ctx, newEarliestAvailableNonce)
}
if newEarliestAvailableNonce > earliestNounce {
if newEarliestAvailableNonce > earliestNonce {
// some attestations were pruned and we need to update the state for it
k.SetEarliestAvailableAttestationNonce(ctx, newEarliestAvailableNonce)
ctx.Logger().Debug(
"pruned attestations from Blobstream store",
"count",
newEarliestAvailableNonce-earliestNounce,
newEarliestAvailableNonce-earliestNonce,
"new_earliest_available_nonce",
newEarliestAvailableNonce,
"latest_attestation_nonce",
Expand Down

0 comments on commit f596671

Please sign in to comment.