Skip to content

Commit

Permalink
Ensure Single Context Used for Beacon Node Cancelation on SIGTERM (#5671
Browse files Browse the repository at this point in the history
)

* ensure single point of entry for ctx and cancelation of expensive func
  • Loading branch information
rauljordan authored Apr 29, 2020
1 parent 5636cd3 commit 9415519
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 93 deletions.
5 changes: 5 additions & 0 deletions beacon-chain/db/kv/regen_historical_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func (kv *Store) regenHistoricalStates(ctx context.Context) error {
return err
}
for i := lastArchivedIndex; i <= lastSavedBlockArchivedIndex; i++ {
// This is an expensive operation, so we check if the context was canceled
// at any point in the iteration.
if err := ctx.Err(); err != nil {
return err
}
targetSlot := startSlot + slotsPerArchivedPoint
filter := filters.NewFilter().SetStartSlot(startSlot + 1).SetEndSlot(targetSlot)
blocks, err := kv.Blocks(ctx, filter)
Expand Down
Loading

0 comments on commit 9415519

Please sign in to comment.