Skip to content

Commit 657cbcf

Browse files
committed
Detect sync issues in EthereumType coins
1 parent 98f0df1 commit 657cbcf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/worker.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,7 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
24182418
start := time.Now().UTC()
24192419
vi := common.GetVersionInfo()
24202420
inSync, bestHeight, lastBlockTime, startSync := w.is.GetSyncState()
2421+
blockPeriod := w.is.GetAvgBlockPeriod()
24212422
if !inSync && !w.is.InitialSync {
24222423
// if less than 5 seconds into syncing, return inSync=true to avoid short time not in sync reports that confuse monitoring
24232424
if startSync.Add(5 * time.Second).After(start) {
@@ -2435,6 +2436,13 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
24352436
inSync = false
24362437
inSyncMempool = false
24372438
}
2439+
// for networks with stable block period, set not in sync if last sync more than 12 block periods ago
2440+
if inSync && blockPeriod > 0 && w.chainType == bchain.ChainEthereumType {
2441+
threshold := 12 * time.Duration(blockPeriod) * time.Second
2442+
if lastBlockTime.Add(threshold).Before(time.Now().UTC()) {
2443+
inSync = false
2444+
}
2445+
}
24382446
var columnStats []common.InternalStateColumn
24392447
var internalDBSize int64
24402448
if internal {

0 commit comments

Comments
 (0)