From 584a5581c89ed6c2a014a103a1a03ea69fb02245 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 27 Aug 2020 12:43:37 +0700 Subject: [PATCH] show "Done!" message only if stage took more than 30 sec (#977) --- eth/stagedsync/state.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eth/stagedsync/state.go b/eth/stagedsync/state.go index 59215bded..2cc9e97b4 100644 --- a/eth/stagedsync/state.go +++ b/eth/stagedsync/state.go @@ -3,6 +3,7 @@ package stagedsync import ( "fmt" "runtime" + "time" "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages" @@ -170,6 +171,7 @@ func (s *State) runStage(stage *Stage, db ethdb.Getter, tx ethdb.Getter) error { } index, stage := s.CurrentStage() + start := time.Now() message := fmt.Sprintf("Sync stage %d/%d. %v...", index+1, s.Len(), stage.Description) log.Info(message) @@ -178,7 +180,9 @@ func (s *State) runStage(stage *Stage, db ethdb.Getter, tx ethdb.Getter) error { return err } - log.Info(fmt.Sprintf("%s DONE!", message)) + if time.Since(start) > 30*time.Second { + log.Info(fmt.Sprintf("%s DONE!", message)) + } return nil } @@ -186,6 +190,7 @@ func (s *State) UnwindStage(unwind *UnwindState, db ethdb.GetterPutter, tx ethdb if hasTx, ok := tx.(ethdb.HasTx); ok && hasTx.Tx() != nil { db = tx } + start := time.Now() log.Info("Unwinding...", "stage", string(stages.DBKeys[unwind.Stage])) stage, err := s.StageByID(unwind.Stage) if err != nil { @@ -212,7 +217,9 @@ func (s *State) UnwindStage(unwind *UnwindState, db ethdb.GetterPutter, tx ethdb return err } - log.Info("Unwinding... DONE!") + if time.Since(start) > 30*time.Second { + log.Info("Unwinding... DONE!") + } return nil }