Reverted async await to promise.
This commit is contained in:
parent
ad5c2dae93
commit
3ee90bdbef
39
index.js
39
index.js
@ -10,31 +10,36 @@ const node = new FullNode(config.bcoin);
|
||||
logger.log('debug',
|
||||
'Debug mode started');
|
||||
|
||||
(async () => {
|
||||
logger.log('debug',
|
||||
'Starting Full Node');
|
||||
node.open()
|
||||
.then()
|
||||
|
||||
await node.open();
|
||||
await node.connect();
|
||||
|
||||
node.on('connect', (entry, block) => {
|
||||
block.height = entry.height;
|
||||
processBlock(block);
|
||||
node.open()
|
||||
.then(() => {
|
||||
node.connect().then(() => {
|
||||
node.startSync();
|
||||
});
|
||||
});
|
||||
|
||||
node.on('tx', (tx) => {
|
||||
logger.log('debug',
|
||||
'%s added to mempool.', tx.txid());
|
||||
});
|
||||
node.chain.on('connect', (entry, block) => {
|
||||
console.log(entry.height);
|
||||
processBlock(entry, block);
|
||||
});
|
||||
|
||||
node.startSync();
|
||||
})();
|
||||
node.mempool.on('tx', (tx) => {
|
||||
console.log(tx);
|
||||
});
|
||||
|
||||
function processBlock(block) {
|
||||
node.chain.on('full', () => {
|
||||
node.mempool.getHistory().then(console.log);
|
||||
});
|
||||
|
||||
function processBlock(entry, block) {
|
||||
block.hash = util.revHex(block.hash().toString('hex'));
|
||||
logger.log('debug',
|
||||
`New Block Height: ${block.height}, Hash: ${block.hash}`);
|
||||
|
||||
console.log(entry);
|
||||
|
||||
const b = new Block({
|
||||
hash: block.hash,
|
||||
size: block.size,
|
||||
@ -46,7 +51,7 @@ function processBlock(block) {
|
||||
nonce: block.nonce,
|
||||
bits: block.bits,
|
||||
difficulty: block.bits,
|
||||
chainwork: 0,
|
||||
chainwork: entry.chainwork,
|
||||
confirmations: 0,
|
||||
previousBlockHash: block.previousBlockHash,
|
||||
nextBlockHash: 0,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user