diff --git a/packages/core-blockchain/src/blockchain.ts b/packages/core-blockchain/src/blockchain.ts index b68e9fee85..9af8874e1b 100644 --- a/packages/core-blockchain/src/blockchain.ts +++ b/packages/core-blockchain/src/blockchain.ts @@ -63,6 +63,7 @@ export class Blockchain implements blockchain.IBlockchain { protected blockProcessor: BlockProcessor; private actions: any; private missedBlocks: number = 0; + private lastCheckNetworkHealthTs: number = 0; /** * Create a new blockchain manager instance. @@ -577,6 +578,13 @@ export class Blockchain implements blockchain.IBlockchain { ) { this.missedBlocks = 0; + // do not check network health here more than every 10 minutes + const nowTs = Date.now(); + if (nowTs - this.lastCheckNetworkHealthTs < 10 * 60 * 1000) { + return; + } + this.lastCheckNetworkHealthTs = nowTs; + const networkStatus = await this.p2p.getMonitor().checkNetworkHealth(); if (networkStatus.forked) { this.state.numberOfBlocksToRollback = networkStatus.blocksToRollback; diff --git a/packages/core-blockchain/src/machines/blockchain.ts b/packages/core-blockchain/src/machines/blockchain.ts index 3b67aa1b9c..7721a77ceb 100644 --- a/packages/core-blockchain/src/machines/blockchain.ts +++ b/packages/core-blockchain/src/machines/blockchain.ts @@ -36,6 +36,7 @@ export const blockchainMachine: any = Machine({ WAKEUP: "syncWithNetwork", NEWBLOCK: "newBlock", STOP: "stopped", + FORK: "fork", }, }, newBlock: {