Crash on reindex

- Removed unneeded cancellation error and handlers for it.
This commit is contained in:
Chris Kleeschulte 2015-09-16 10:22:24 -04:00
parent 4ee11ed73b
commit c9d4dc276f
5 changed files with 3 additions and 23 deletions

View File

@ -15,14 +15,11 @@ Consensus.BlockExists = createError('BlockExists', Consensus);
var Transaction = createError('Transaction', BitcoreNodeError);
Transaction.NotFound = createError('NotFound', Transaction);
var Cancellation = createError('Cancellation', BitcoreNodeError);
module.exports = {
Error: BitcoreNodeError,
NoOutputs: NoOutputs,
NoOutput: NoOutput,
Wallet: Wallet,
Consensus: Consensus,
Transaction: Transaction,
Cancellation: Cancellation
Transaction: Transaction
};

View File

@ -22,7 +22,6 @@ function Node(config) {
this.network = null;
this.services = {};
this._unloadedServices = [];
this.started = false;
// TODO type check the arguments of config.services
if (config.services) {
@ -187,24 +186,16 @@ Node.prototype.start = function(callback) {
self._startService(service, next);
},
function(err) {
if (err instanceof errors.Cancellation) {
self.cancellation = true;
return callback(err);
} else if (err) {
if (err) {
return callback(err);
}
self.emit('ready');
self.started = true;
callback();
}
);
};
Node.prototype.stop = function(callback) {
if (!this.started && !this.cancellation) {
this.pendingStop = true;
return;
}
log.info('Beginning shutdown');
var self = this;
var services = this.getServiceOrder().reverse();

View File

@ -216,10 +216,7 @@ function start(options) {
});
node.start(function(err) {
if (err instanceof errors.Cancellation) {
log.warn('Cancelled start up of all services');
start.cleanShutdown(process, node);
} else if(err) {
if(err) {
log.error('Failed to start services');
if (err.stack) {
log.error(err.stack);

View File

@ -159,10 +159,6 @@ Bitcoin.prototype.start = function(callback) {
}
if (self._reindex) {
var interval = setInterval(function() {
if (self.node.pendingStop) {
clearInterval(interval);
return callback(new errors.Cancellation(), false);
}
var percentSynced = bindings.syncPercentage();
log.info("Bitcoin Core Daemon Reindex Percentage: " + percentSynced);
if (percentSynced >= 100) {

View File

@ -324,7 +324,6 @@ describe('Bitcore Node', function() {
describe('#stop', function() {
it('will call stop for each service', function(done) {
var node = new Node(baseConfig);
node.started = true;
function TestService() {}
util.inherits(TestService, BaseService);
TestService.prototype.stop = sinon.stub().callsArg(0);