Adding optional Blockstream esplora backend support.

This commit is contained in:
Simon Lindh
2019-10-22 17:09:07 +08:00
parent 143949bab4
commit 136b6eb76e
12 changed files with 1361 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
const config = require('../../mempool-config.json');
import bitcoinApi from './bitcoin-api-wrapper';
import bitcoinApi from './bitcoin/bitcoin-api-factory';
import { DB } from '../database';
import { IBlock, ITransaction } from '../interfaces';
import memPool from './mempool';
@@ -56,7 +56,7 @@ class Blocks {
block = storedBlock;
} else {
const blockHash = await bitcoinApi.getBlockHash(this.currentBlockHeight);
block = await bitcoinApi.getBlock(blockHash, 1);
block = await bitcoinApi.getBlock(blockHash);
const coinbase = await memPool.getRawTransaction(block.tx[0], true);
if (coinbase && coinbase.totalOut) {
@@ -74,6 +74,7 @@ class Blocks {
transactions.push(mempool[block.tx[i]]);
found++;
} else {
console.log(`Fetching block tx ${i} of ${block.tx.length}`);
const tx = await memPool.getRawTransaction(block.tx[i]);
if (tx) {
transactions.push(tx);