itns-sidechain/docs/Examples/fullnode.js

29 lines
528 B
JavaScript
Raw Normal View History

2017-03-24 16:26:34 -07:00
'use strict';
2017-08-09 16:38:20 +04:00
const bcoin = require('../..');
const FullNode = bcoin.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',
2017-07-17 16:36:01 -07:00
db: 'memory',
workers: true
2017-03-24 16:26:34 -07:00
});
2017-07-17 16:36:01 -07:00
(async () => {
2017-03-24 16:26:34 -07:00
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();
2017-08-09 16:38:20 +04:00
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});