commit
6e8d452174
@ -31,6 +31,15 @@ function main(parentServicesPath, additionalServices) {
|
||||
node.cli.main(parentServicesPath, additionalServices);
|
||||
}
|
||||
|
||||
// Gracefully Shut Down
|
||||
process.on('SIGTERM', function () {
|
||||
console.log("Shutting down flocore-node")
|
||||
node.stop(function() {
|
||||
console.log("flocore-node successfully stopped!")
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -201,12 +201,13 @@ function cleanShutdown(_process, node) {
|
||||
return _process.exit(1);
|
||||
}
|
||||
log.info('Halted');
|
||||
_process.exit(0);
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
function exitHandler(options, _process, node, err) {
|
||||
if (err) {
|
||||
// Handle and log errors other than SIGINT shutdown
|
||||
if (err && err !== "SIGINT") {
|
||||
log.error('uncaught exception:', err);
|
||||
if(err.stack) {
|
||||
log.error(err.stack);
|
||||
@ -218,6 +219,7 @@ function exitHandler(options, _process, node, err) {
|
||||
_process.exit(-1);
|
||||
});
|
||||
}
|
||||
// Handle SIGINT (Ctrl+C)
|
||||
if (options.sigint) {
|
||||
if (!shuttingDown) {
|
||||
shuttingDown = true;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var Block = require('fcoin').block;
|
||||
var Block = require('fcoin').Block;
|
||||
// stores -- block header as key, block itself as value (optionally)
|
||||
|
||||
function Encoding(servicePrefix) {
|
||||
|
||||
@ -7,7 +7,8 @@ var index = require('../../');
|
||||
var log = index.log;
|
||||
var utils = require('../../utils');
|
||||
var async = require('async');
|
||||
var BN = require('bn.js');
|
||||
// var BN = require('bn.js');
|
||||
var BN = require('bcrypto/lib/bn.js')
|
||||
var consensus = require('fcoin').consensus;
|
||||
var assert = require('assert');
|
||||
var constants = require('../../constants');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var tx = require('fcoin').tx;
|
||||
var tx = require('fcoin').TX;
|
||||
|
||||
function Encoding(servicePrefix) {
|
||||
this.servicePrefix = servicePrefix;
|
||||
|
||||
@ -3,65 +3,50 @@
|
||||
var index = require('../../');
|
||||
var log = index.log;
|
||||
var bcoin = require('fcoin');
|
||||
var bzmq = require('bzmq');
|
||||
// var bzmq = require('bzmq');
|
||||
|
||||
var Bcoin = function(options) {
|
||||
this._config = this._getConfig(options);
|
||||
};
|
||||
|
||||
Bcoin.prototype.start = function(callback) {
|
||||
var self = this;
|
||||
self._bcoin = bcoin.fullnode(self._config);
|
||||
this._bcoin = new bcoin.FullNode(this._config);
|
||||
|
||||
bcoin.set(self._config.network || 'main')
|
||||
const walletPlugin = bcoin.wallet.plugin;
|
||||
log.info('Starting fcoin FullNode...');
|
||||
|
||||
// Make fcoin add the wallet plugin
|
||||
self._bcoin.use(walletPlugin)
|
||||
// bzmq allows zmq connections to fcoin
|
||||
self._bcoin.use(bzmq)
|
||||
self._bzmq = self._bcoin.require('zmq')
|
||||
|
||||
log.info('Starting Fcoin full node...');
|
||||
|
||||
self._bcoin.open().then(function() {
|
||||
|
||||
// Startup the wallet plugin
|
||||
self._walletdb = self._bcoin.require('walletdb');
|
||||
self._walletdb.open().then(function() {
|
||||
|
||||
// Continue bcoin startup
|
||||
self._bcoin.connect().then(function() {
|
||||
log.info('Waiting for Fcoin to sync');
|
||||
self._bcoin.startSync();
|
||||
// this will instruct the p2p service to start trying to connect to bcoin right away
|
||||
callback();
|
||||
});
|
||||
|
||||
})
|
||||
this._bcoin.open().then(() => {
|
||||
this._bcoin.connect().then(() => {
|
||||
this._bcoin.startSync();
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Bcoin.prototype.stop = function() {
|
||||
this._bcoin.stopSync();
|
||||
this._bcoin.disconnect();
|
||||
this._bcoin.close();
|
||||
Bcoin.prototype.stop = function(callback) {
|
||||
this._bcoin.close().then(() => {
|
||||
log.info("fcoin shutdown")
|
||||
callback()
|
||||
});
|
||||
};
|
||||
|
||||
// --- privates
|
||||
|
||||
Bcoin.prototype._getConfig = function(options) {
|
||||
var config = {
|
||||
db: 'leveldb',
|
||||
checkpoints: true,
|
||||
network: options.network || 'main',
|
||||
listen: true,
|
||||
port: options.port,
|
||||
|
||||
logFile: true,
|
||||
logConsole: true,
|
||||
logLevel: 'info',
|
||||
port: options.port,
|
||||
persistent: true,
|
||||
|
||||
// indexTx: true,
|
||||
// indexAddress: true,
|
||||
|
||||
checkpoints: true,
|
||||
memory: false,
|
||||
workers: true,
|
||||
config: true
|
||||
listen: true
|
||||
};
|
||||
if (options.prefix) {
|
||||
config.prefix = options.prefix;
|
||||
|
||||
@ -8,7 +8,8 @@ var log = index.log;
|
||||
var BaseService = require('../../service');
|
||||
var assert = require('assert');
|
||||
var Bcoin = require('./bcoin');
|
||||
var BcoinTx = require('fcoin').tx;
|
||||
var BcoinBlock = require('fcoin').Block;
|
||||
var BcoinTx = require('fcoin').TX;
|
||||
var Networks = require('flocore-lib').Networks;
|
||||
var BitcoreRPC = require('bitcoind-rpc');
|
||||
var LRU = require('lru-cache');
|
||||
@ -89,7 +90,7 @@ P2P.prototype.getP2PBlock = function(opts, callback) {
|
||||
|
||||
self.once(opts.blockHash, callback);
|
||||
|
||||
peer.sendMessage(self.messages.GetBlocks(blockFilter));
|
||||
peer.sendMessage(self.messages.GetBlocks(blockFilter, { Block: BcoinBlock }));
|
||||
};
|
||||
|
||||
P2P.prototype.getHeaders = function(filter) {
|
||||
@ -277,7 +278,7 @@ P2P.prototype._initP2P = function() {
|
||||
if (this.node.network === 'regtest') {
|
||||
Networks.enableRegtest();
|
||||
}
|
||||
this.messages = new p2p.Messages({ network: Networks.get(this.node.network), Transaction: BcoinTx });
|
||||
this.messages = new p2p.Messages({ network: Networks.get(this.node.network), Transaction: BcoinTx, Block: BcoinBlock });
|
||||
this._peerHeights = [];
|
||||
this._peers = [];
|
||||
this._peerIndex = 0;
|
||||
@ -432,9 +433,6 @@ P2P.prototype._setResourceFilter = function(filter) {
|
||||
};
|
||||
|
||||
P2P.prototype._startBcoin = function(callback) {
|
||||
|
||||
var self = this;
|
||||
|
||||
var network;
|
||||
var port;
|
||||
if (['livenet', 'live', 'main', 'mainnet'].indexOf(this.node.network) !== -1) {
|
||||
@ -448,13 +446,13 @@ P2P.prototype._startBcoin = function(callback) {
|
||||
port = this._configPeers[0].port || 48444;
|
||||
}
|
||||
|
||||
self._bcoin = new Bcoin({
|
||||
this._bcoin = new Bcoin({
|
||||
network: network,
|
||||
prefix: self.node.datadir,
|
||||
prefix: this.node.datadir,
|
||||
port: port
|
||||
});
|
||||
|
||||
self._bcoin.start(callback);
|
||||
this._bcoin.start(callback);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var Tx = require('fcoin').tx;
|
||||
var Tx = require('fcoin').TX;
|
||||
|
||||
function Encoding(servicePrefix) {
|
||||
this.servicePrefix = servicePrefix;
|
||||
|
||||
3830
package-lock.json
generated
3830
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -5,7 +5,7 @@
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"author": "BitPay <dev@bitpay.com>",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.2",
|
||||
"main": "./index.js",
|
||||
"repository": "git://github.com/oipwg/flocore-node.git",
|
||||
"homepage": "https://github.com/oipwg/flocore-node",
|
||||
@ -32,23 +32,22 @@
|
||||
"bitcoind-rpc": "^0.7.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"body-parser": "^1.13.3",
|
||||
"bzmq": "^0.1.2",
|
||||
"colors": "^1.1.2",
|
||||
"commander": "^2.8.1",
|
||||
"errno": "^0.1.4",
|
||||
"express": "^4.13.3",
|
||||
"fcoin": "1.0.1",
|
||||
"flocore-lib": "0.15.1",
|
||||
"flocore-p2p": "5.0.0-beta.6",
|
||||
"fcoin": "^1.1.0",
|
||||
"flocore-lib": "^0.15.2",
|
||||
"flocore-message": "^1.0.7",
|
||||
"flocore-p2p": "^5.0.0-beta.8",
|
||||
"florincoind-rpc": "0.7.1",
|
||||
"flosight-api": "^5.0.0-beta.68",
|
||||
"flosight-api": "^5.0.0-beta.73",
|
||||
"flosight-ui": "^5.0.0-beta.72",
|
||||
"leveldown": "^2.0.0",
|
||||
"levelup": "^2.0.0",
|
||||
"liftoff": "^2.2.0",
|
||||
"lodash": "^4.17.4",
|
||||
"lodash": "^4.17.12",
|
||||
"lru-cache": "^4.1.1",
|
||||
"memwatch-next": "^0.3.0",
|
||||
"mkdirp": "0.5.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"socket.io": "^1.4.5",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user