Enable parallel sync only for initial sync
This commit is contained in:
parent
8fb4772331
commit
dffcded306
@ -63,11 +63,15 @@ func (w *SyncWorker) ResyncIndex(onNewBlock bchain.OnNewBlockFunc, initialSync b
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
w.is.FinishedSync(bh)
|
w.is.FinishedSync(bh)
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
case errSynced:
|
case errSynced:
|
||||||
// this is not actually error but flag that resync wasn't necessary
|
// this is not actually error but flag that resync wasn't necessary
|
||||||
w.is.FinishedSyncNoChange()
|
w.is.FinishedSyncNoChange()
|
||||||
w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk()))
|
w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk()))
|
||||||
|
if initialSync {
|
||||||
|
d := time.Since(start)
|
||||||
|
glog.Info("resync: finished in ", d)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +117,8 @@ func (w *SyncWorker) resyncIndex(onNewBlock bchain.OnNewBlockFunc, initialSync b
|
|||||||
}
|
}
|
||||||
// if parallel operation is enabled and the number of blocks to be connected is large,
|
// if parallel operation is enabled and the number of blocks to be connected is large,
|
||||||
// use parallel routine to load majority of blocks
|
// use parallel routine to load majority of blocks
|
||||||
if w.syncWorkers > 1 {
|
// use parallel sync only in case of initial sync because it puts the db to inconsistent state
|
||||||
|
if w.syncWorkers > 1 && initialSync {
|
||||||
remoteBestHeight, err := w.chain.GetBestBlockHeight()
|
remoteBestHeight, err := w.chain.GetBestBlockHeight()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user