From 647a3cb6d39f96d1d2a3fb0a73daa041067bd223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Mon, 3 May 2021 14:08:38 +0200 Subject: [PATCH] blocks: Make fakemode not depend on bitcoind --- blocks/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blocks/index.ts b/blocks/index.ts index 9983bc0..485d186 100644 --- a/blocks/index.ts +++ b/blocks/index.ts @@ -83,15 +83,16 @@ async function setupPeriod(blockCount: number, startHeight: number, endHeight: n export async function bootstrapBlocks() { console.log(`Bootstrapping ${config.mode} block data...`); const createBlock = config.mode === "fake" ? createFakeBlock : createRealBlock; + const callGetblockcount = config.mode === "fake" ? async () => await Promise.resolve(1000) : getblockcount; - let blockCount = await getblockcount(); + let blockCount = await callGetblockcount(); const difficultyPeriodStartHeight = blockCount - (blockCount % 2016); const difficultyPeriodEndHeight = difficultyPeriodStartHeight + 2016; console.log(`Current block height is ${blockCount}`); blocks = await setupPeriod(blockCount, difficultyPeriodStartHeight, difficultyPeriodEndHeight); setInterval(async () => { - const newBlockCount = await getblockcount(); + const newBlockCount = await callGetblockcount(); if (newBlockCount > blockCount) { console.log("Found new block"); if (newBlockCount % 2016 === 0) {