Browse Source

blocks: Make fakemode not depend on bitcoind

master
Hampus Sjöberg 4 years ago
parent
commit
647a3cb6d3
  1. 5
      blocks/index.ts

5
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) {

Loading…
Cancel
Save