mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 09:39:17 +01:00
Fast forward the block fetching if backend has been offline for a while.
This commit is contained in:
parent
4ae6b982e0
commit
2b9be35afa
1 changed files with 5 additions and 0 deletions
|
@ -32,6 +32,11 @@ class Blocks {
|
||||||
this.currentBlockHeight = this.blocks[this.blocks.length - 1].height;
|
this.currentBlockHeight = this.blocks[this.blocks.length - 1].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blockHeightTip - this.currentBlockHeight > config.INITIAL_BLOCK_AMOUNT * 2) {
|
||||||
|
console.log(`${blockHeightTip - this.currentBlockHeight} blocks since tip. Fast forwarding to the ${config.INITIAL_BLOCK_AMOUNT} recent blocks`);
|
||||||
|
this.currentBlockHeight = blockHeightTip - config.INITIAL_BLOCK_AMOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
while (this.currentBlockHeight < blockHeightTip) {
|
while (this.currentBlockHeight < blockHeightTip) {
|
||||||
if (this.currentBlockHeight === 0) {
|
if (this.currentBlockHeight === 0) {
|
||||||
this.currentBlockHeight = blockHeightTip;
|
this.currentBlockHeight = blockHeightTip;
|
||||||
|
|
Loading…
Add table
Reference in a new issue