From 7766934abe88ee20218153c95a1e781e7836cd26 Mon Sep 17 00:00:00 2001 From: mfw78 Date: Sun, 15 Oct 2023 12:55:41 +0000 Subject: [PATCH] fix: in sync --- src/domain/chainContext.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/domain/chainContext.ts b/src/domain/chainContext.ts index fd1f675..fcd326e 100644 --- a/src/domain/chainContext.ts +++ b/src/domain/chainContext.ts @@ -191,6 +191,14 @@ export class ChainContext { toBlock = toBlock > currentBlock.number ? currentBlock.number : toBlock; + // This happens when the watch-tower has restarted and the last processed block is + // the current block. Therefore the `fromBlock` is the current block + 1, which is + // greater than the current block number. In this case, we are in sync. + if (fromBlock > currentBlock.number) { + this.sync = ChainSync.IN_SYNC; + break; + } + log.debug( `Reaching tip of chain, current block number: ${currentBlock.number}` );