Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed May 22, 2024
1 parent 2b709c3 commit 7d9a966
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions snow/engine/snowman/bootstrap/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,22 @@ func execute(
defer func() {
iterator.Release()

log("compacting database after executing blocks...")
if err := db.Compact(nil, nil); err != nil {
// Not a fatal error, log and move on.
log("failed to compact bootstrap database after executing blocks",
zap.Error(err),
)
halted := haltable.Halted()
if !halted {
log("compacting database after executing blocks...")
if err := db.Compact(nil, nil); err != nil {
// Not a fatal error, log and move on.
log("failed to compact bootstrap database after executing blocks",
zap.Error(err),
)
}
}

numProcessed := totalNumberToProcess - tree.Len()
log("executed blocks",
zap.Uint64("numExecuted", numProcessed),
zap.Uint64("numToExecute", totalNumberToProcess),
zap.Bool("halted", haltable.Halted()),
zap.Bool("halted", halted),
zap.Duration("duration", time.Since(startTime)),
)
}()
Expand Down Expand Up @@ -226,7 +229,10 @@ func execute(

processedSinceIteratorRelease = 0
iterator.Release()
iterator = interval.GetBlockIteratorWithStart(db, height)
// We specify the starting key of the iterator so that the
// underlying database doesn't need to scan over the, potentially
// not yet compacted, blocks we just deleted.
iterator = interval.GetBlockIteratorWithStart(db, height+1)
}

if now := time.Now(); now.After(timeOfNextLog) {
Expand Down

0 comments on commit 7d9a966

Please sign in to comment.