From 8bb885e85b3ed1b820fcc07708f63a7584fb44b7 Mon Sep 17 00:00:00 2001 From: Jacky Wang Date: Fri, 6 May 2022 15:38:03 -0700 Subject: [PATCH] [downloader] fix the local test. Do not set sync mode when bootstrapping. (#4163) --- hmy/downloader/longrange.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hmy/downloader/longrange.go b/hmy/downloader/longrange.go index 44c8506c0..b4efbf192 100644 --- a/hmy/downloader/longrange.go +++ b/hmy/downloader/longrange.go @@ -19,9 +19,6 @@ import ( func (d *Downloader) doLongRangeSync() (int, error) { var totalInserted int - d.startSyncing() - defer d.finishSyncing() - for { ctx, cancel := context.WithCancel(d.ctx) @@ -71,6 +68,15 @@ func (lsi *lrSyncIter) doLongRangeSync() error { if err != nil { return err } + if curBN := lsi.bc.CurrentBlock().NumberU64(); bn <= curBN { + lsi.logger.Info().Uint64("current number", curBN).Uint64("target number", bn). + Msg("early return of long range sync") + return nil + } + + lsi.d.startSyncing() + defer lsi.d.finishSyncing() + lsi.logger.Info().Uint64("target number", bn).Msg("estimated remote current number") lsi.d.status.setTargetBN(bn)