From fe72e9a0a288d331ca28a585aa49ceb0d50d1c09 Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Wed, 8 Apr 2020 18:45:44 +0200 Subject: [PATCH] add dynamic switch of startup mode --- tracker/blockchain-processor.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tracker/blockchain-processor.js b/tracker/blockchain-processor.js index 27caccd7..0ddbac0c 100644 --- a/tracker/blockchain-processor.js +++ b/tracker/blockchain-processor.js @@ -55,9 +55,12 @@ class BlockchainProcessor extends AbstractProcessor { * @returns {Promise} */ async catchup() { - // Consider that we are in IBD mode if Dojo is far in the past const highest = await db.getHighestBlock() - this.isIBD = highest.blockHeight < 570000 + const info = await this.client.getblockchaininfo() + const daemonNbHeaders = info.headers + + // Consider that we are in IBD mode if Dojo is far in the past (> 13,000 blocks) + this.isIBD = highest.blockHeight < daemonNbHeaders - 13000 if (this.isIBD) return this.catchupIBDMode()