diff --git a/pkg/snapshot/publisher.go b/pkg/snapshot/publisher.go index 432f7fa..781cea4 100644 --- a/pkg/snapshot/publisher.go +++ b/pkg/snapshot/publisher.go @@ -183,13 +183,17 @@ func (p *Publisher) checkBatchSize(tx *sqlx.Tx, maxBatchSize uint) (*sqlx.Tx, er return tx, nil } -// printNodeCounters prints number of node processed. -func (p *Publisher) printNodeCounters() { +// logNodeCounters periodically logs the number of node processed. +func (p *Publisher) logNodeCounters() { t := time.NewTicker(logInterval) for range t.C { - logrus.Infof("total runtime: %s", time.Now().Sub(p.startTime).String()) - logrus.Infof("processed state nodes: %d", atomic.LoadUint64(&p.stateNodeCounter)) - logrus.Infof("processed storage nodes: %d", atomic.LoadUint64(&p.storageNodeCounter)) - logrus.Infof("processed code nodes: %d", atomic.LoadUint64(&p.codeNodeCounter)) + p.printNodeCounters() } } + +func (p *Publisher) printNodeCounters() { + logrus.Infof("runtime: %s", time.Now().Sub(p.startTime).String()) + logrus.Infof("processed state nodes: %d", atomic.LoadUint64(&p.stateNodeCounter)) + logrus.Infof("processed storage nodes: %d", atomic.LoadUint64(&p.storageNodeCounter)) + logrus.Infof("processed code nodes: %d", atomic.LoadUint64(&p.codeNodeCounter)) +} diff --git a/pkg/snapshot/service.go b/pkg/snapshot/service.go index 4a14429..a684741 100644 --- a/pkg/snapshot/service.go +++ b/pkg/snapshot/service.go @@ -136,8 +136,10 @@ func (s *Service) createSnapshot(it trie.NodeIterator, trieDB *trie.Database, he return err } - go s.ipfsPublisher.printNodeCounters() + go s.ipfsPublisher.logNodeCounters() defer func() { + logrus.Info("----- final counts -----") + s.ipfsPublisher.printNodeCounters() if rec := recover(); rec != nil { shared.Rollback(tx) panic(rec)