cumulative index stage: ctrl+C support

This commit is contained in:
alex.sharov 2023-04-19 10:56:02 +07:00
parent 61deabc561
commit c733596f59

View File

@ -34,7 +34,7 @@ func SpawnStageCumulativeIndex(cfg CumulativeIndexCfg, s *StageState, tx kv.RwTx
if !useExternalTx {
var err error
tx, err = cfg.db.BeginRw(context.Background())
tx, err = cfg.db.BeginRw(ctx)
if err != nil {
return err
}
@ -102,6 +102,8 @@ func SpawnStageCumulativeIndex(cfg CumulativeIndexCfg, s *StageState, tx kv.RwTx
// Check for logs
select {
case <-ctx.Done():
return ctx.Err()
case <-logEvery.C:
log.Info(fmt.Sprintf("[%s] Wrote Cumulative Index", s.LogPrefix()),
"gasUsed", cumulativeGasUsed.String(), "now", currentBlockNumber, "blk/sec", float64(currentBlockNumber-prevProgress)/float64(logInterval/time.Second))