itns-sidechain/examples/node.js

27 lines
447 B
JavaScript
Raw Normal View History

2017-03-24 16:26:34 -07:00
'use strict';
2017-06-29 20:54:07 -07:00
const FullNode = require('bcoin/lib/node/fullnode');
2017-03-24 16:26:34 -07:00
2017-06-29 20:54:07 -07:00
const node = new FullNode({
2017-03-24 16:26:34 -07:00
network: 'testnet',
db: 'memory'
});
async function main() {
await node.open();
await node.connect();
2017-06-29 20:54:07 -07:00
node.on('connect', (entry, block) => {
2017-03-24 16:26:34 -07:00
console.log('%s (%d) added to chain.', entry.rhash(), entry.height);
});
2017-06-29 20:54:07 -07:00
node.on('tx', (tx) => {
2017-03-24 16:26:34 -07:00
console.log('%s added to mempool.', tx.txid());
});
node.startSync();
}
main();