[downloader] fix the local test. Do not set sync mode when bootstrapping. (#4163)

pull/4168/head
Jacky Wang 3 years ago committed by GitHub
parent 22e595df82
commit 8bb885e85b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      hmy/downloader/longrange.go

@ -19,9 +19,6 @@ import (
func (d *Downloader) doLongRangeSync() (int, error) { func (d *Downloader) doLongRangeSync() (int, error) {
var totalInserted int var totalInserted int
d.startSyncing()
defer d.finishSyncing()
for { for {
ctx, cancel := context.WithCancel(d.ctx) ctx, cancel := context.WithCancel(d.ctx)
@ -71,6 +68,15 @@ func (lsi *lrSyncIter) doLongRangeSync() error {
if err != nil { if err != nil {
return err 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.logger.Info().Uint64("target number", bn).Msg("estimated remote current number")
lsi.d.status.setTargetBN(bn) lsi.d.status.setTargetBN(bn)

Loading…
Cancel
Save