node start wired up
This commit is contained in:
parent
aaef1c7273
commit
06b24d85b7
1
index.js
1
index.js
@ -10,3 +10,4 @@ Api.listen(3000, () => {
|
|||||||
'listening on port 3000');
|
'listening on port 3000');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
node.start();
|
||||||
|
|||||||
@ -6,18 +6,20 @@ const logger = require('../../lib/logger');
|
|||||||
const db = require('../../lib/db');
|
const db = require('../../lib/db');
|
||||||
const util = require('../../lib/util');
|
const util = require('../../lib/util');
|
||||||
|
|
||||||
node.open()
|
|
||||||
.then(() => {
|
function start() {
|
||||||
|
node.open()
|
||||||
|
.then(() => {
|
||||||
node.connect().then(() => {
|
node.connect().then(() => {
|
||||||
node.startSync();
|
node.startSync();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
node.chain.on('connect', (entry, block) => {
|
node.chain.on('connect', (entry, block) => {
|
||||||
processBlock(entry, block);
|
processBlock(entry, block);
|
||||||
});
|
});
|
||||||
|
|
||||||
function processBlock(entry, block, cb) {
|
function processBlock(entry, block, cb) {
|
||||||
block.hash = util.revHex(block.hash().toString('hex'))
|
block.hash = util.revHex(block.hash().toString('hex'))
|
||||||
const b = new BlockSchema({
|
const b = new BlockSchema({
|
||||||
hash: block.hash,
|
hash: block.hash,
|
||||||
@ -46,4 +48,9 @@ function processBlock(entry, block, cb) {
|
|||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
start,
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user