Crash on reindex
- Removed unneeded cancellation error and handlers for it.
This commit is contained in:
parent
4ee11ed73b
commit
c9d4dc276f
@ -15,14 +15,11 @@ Consensus.BlockExists = createError('BlockExists', Consensus);
|
|||||||
var Transaction = createError('Transaction', BitcoreNodeError);
|
var Transaction = createError('Transaction', BitcoreNodeError);
|
||||||
Transaction.NotFound = createError('NotFound', Transaction);
|
Transaction.NotFound = createError('NotFound', Transaction);
|
||||||
|
|
||||||
var Cancellation = createError('Cancellation', BitcoreNodeError);
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Error: BitcoreNodeError,
|
Error: BitcoreNodeError,
|
||||||
NoOutputs: NoOutputs,
|
NoOutputs: NoOutputs,
|
||||||
NoOutput: NoOutput,
|
NoOutput: NoOutput,
|
||||||
Wallet: Wallet,
|
Wallet: Wallet,
|
||||||
Consensus: Consensus,
|
Consensus: Consensus,
|
||||||
Transaction: Transaction,
|
Transaction: Transaction
|
||||||
Cancellation: Cancellation
|
|
||||||
};
|
};
|
||||||
|
|||||||
11
lib/node.js
11
lib/node.js
@ -22,7 +22,6 @@ function Node(config) {
|
|||||||
this.network = null;
|
this.network = null;
|
||||||
this.services = {};
|
this.services = {};
|
||||||
this._unloadedServices = [];
|
this._unloadedServices = [];
|
||||||
this.started = false;
|
|
||||||
|
|
||||||
// TODO type check the arguments of config.services
|
// TODO type check the arguments of config.services
|
||||||
if (config.services) {
|
if (config.services) {
|
||||||
@ -187,24 +186,16 @@ Node.prototype.start = function(callback) {
|
|||||||
self._startService(service, next);
|
self._startService(service, next);
|
||||||
},
|
},
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err instanceof errors.Cancellation) {
|
if (err) {
|
||||||
self.cancellation = true;
|
|
||||||
return callback(err);
|
|
||||||
} else if (err) {
|
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
self.emit('ready');
|
self.emit('ready');
|
||||||
self.started = true;
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Node.prototype.stop = function(callback) {
|
Node.prototype.stop = function(callback) {
|
||||||
if (!this.started && !this.cancellation) {
|
|
||||||
this.pendingStop = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.info('Beginning shutdown');
|
log.info('Beginning shutdown');
|
||||||
var self = this;
|
var self = this;
|
||||||
var services = this.getServiceOrder().reverse();
|
var services = this.getServiceOrder().reverse();
|
||||||
|
|||||||
@ -216,10 +216,7 @@ function start(options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
node.start(function(err) {
|
node.start(function(err) {
|
||||||
if (err instanceof errors.Cancellation) {
|
if(err) {
|
||||||
log.warn('Cancelled start up of all services');
|
|
||||||
start.cleanShutdown(process, node);
|
|
||||||
} else if(err) {
|
|
||||||
log.error('Failed to start services');
|
log.error('Failed to start services');
|
||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
log.error(err.stack);
|
log.error(err.stack);
|
||||||
|
|||||||
@ -159,10 +159,6 @@ Bitcoin.prototype.start = function(callback) {
|
|||||||
}
|
}
|
||||||
if (self._reindex) {
|
if (self._reindex) {
|
||||||
var interval = setInterval(function() {
|
var interval = setInterval(function() {
|
||||||
if (self.node.pendingStop) {
|
|
||||||
clearInterval(interval);
|
|
||||||
return callback(new errors.Cancellation(), false);
|
|
||||||
}
|
|
||||||
var percentSynced = bindings.syncPercentage();
|
var percentSynced = bindings.syncPercentage();
|
||||||
log.info("Bitcoin Core Daemon Reindex Percentage: " + percentSynced);
|
log.info("Bitcoin Core Daemon Reindex Percentage: " + percentSynced);
|
||||||
if (percentSynced >= 100) {
|
if (percentSynced >= 100) {
|
||||||
|
|||||||
@ -324,7 +324,6 @@ describe('Bitcore Node', function() {
|
|||||||
describe('#stop', function() {
|
describe('#stop', function() {
|
||||||
it('will call stop for each service', function(done) {
|
it('will call stop for each service', function(done) {
|
||||||
var node = new Node(baseConfig);
|
var node = new Node(baseConfig);
|
||||||
node.started = true;
|
|
||||||
function TestService() {}
|
function TestService() {}
|
||||||
util.inherits(TestService, BaseService);
|
util.inherits(TestService, BaseService);
|
||||||
TestService.prototype.stop = sinon.stub().callsArg(0);
|
TestService.prototype.stop = sinon.stub().callsArg(0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user