Store sync and mempool sync state to internal state
parent
291e99ba5f
commit
af064a3921
|
@ -350,8 +350,11 @@ func syncMempoolLoop() {
|
||||||
glog.Info("syncMempoolLoop starting")
|
glog.Info("syncMempoolLoop starting")
|
||||||
// resync mempool about every minute if there are no chanSyncMempool requests, with debounce 1 second
|
// resync mempool about every minute if there are no chanSyncMempool requests, with debounce 1 second
|
||||||
tickAndDebounce(resyncMempoolPeriodMs*time.Millisecond, debounceResyncMempoolMs*time.Millisecond, chanSyncMempool, func() {
|
tickAndDebounce(resyncMempoolPeriodMs*time.Millisecond, debounceResyncMempoolMs*time.Millisecond, chanSyncMempool, func() {
|
||||||
|
common.IS.StartedMempoolSync()
|
||||||
if err := chain.ResyncMempool(onNewTxAddr); err != nil {
|
if err := chain.ResyncMempool(onNewTxAddr); err != nil {
|
||||||
glog.Error("syncMempoolLoop ", errors.ErrorStack(err))
|
glog.Error("syncMempoolLoop ", errors.ErrorStack(err))
|
||||||
|
} else {
|
||||||
|
common.IS.FinishedMempoolSync()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
glog.Info("syncMempoolLoop stopped")
|
glog.Info("syncMempoolLoop stopped")
|
||||||
|
|
|
@ -47,6 +47,7 @@ var errSynced = errors.New("synced")
|
||||||
// onNewBlock is called when new block is connected, but not in initial parallel sync
|
// onNewBlock is called when new block is connected, but not in initial parallel sync
|
||||||
func (w *SyncWorker) ResyncIndex(onNewBlock func(hash string)) error {
|
func (w *SyncWorker) ResyncIndex(onNewBlock func(hash string)) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
common.IS.StartedSync()
|
||||||
|
|
||||||
err := w.resyncIndex(onNewBlock)
|
err := w.resyncIndex(onNewBlock)
|
||||||
|
|
||||||
|
@ -56,6 +57,10 @@ func (w *SyncWorker) ResyncIndex(onNewBlock func(hash string)) error {
|
||||||
glog.Info("resync: finished in ", d)
|
glog.Info("resync: finished in ", d)
|
||||||
w.metrics.IndexResyncDuration.Observe(float64(d) / 1e6) // in milliseconds
|
w.metrics.IndexResyncDuration.Observe(float64(d) / 1e6) // in milliseconds
|
||||||
w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk()))
|
w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk()))
|
||||||
|
bh, _, err := w.db.GetBestBlock()
|
||||||
|
if err == nil {
|
||||||
|
common.IS.FinishedSync(bh)
|
||||||
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue