bitcoind: fix check reindex method not found
This commit is contained in:
parent
3fed348cf7
commit
bf67b932de
@ -479,11 +479,14 @@ Bitcoin.prototype._checkReindex = function(node, callback) {
|
|||||||
}
|
}
|
||||||
if (node._reindex) {
|
if (node._reindex) {
|
||||||
interval = setInterval(function() {
|
interval = setInterval(function() {
|
||||||
node.client.syncPercentage(function(err, percentSynced) {
|
node.client.getBlockchainInfo(function(err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return finish(self._wrapRPCError(err));
|
return finish(self._wrapRPCError(err));
|
||||||
}
|
}
|
||||||
|
var percentSynced = response.result.verificationprogress * 100;
|
||||||
|
|
||||||
log.info('Bitcoin Core Daemon Reindex Percentage: ' + percentSynced.toFixed(2));
|
log.info('Bitcoin Core Daemon Reindex Percentage: ' + percentSynced.toFixed(2));
|
||||||
|
|
||||||
if (Math.round(percentSynced) >= 100) {
|
if (Math.round(percentSynced) >= 100) {
|
||||||
node._reindex = false;
|
node._reindex = false;
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@ -728,13 +728,13 @@ describe('Bitcoin Service', function() {
|
|||||||
after(function() {
|
after(function() {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
});
|
});
|
||||||
it('give error from client syncpercentage', function(done) {
|
it('give error from client getblockchaininfo', function(done) {
|
||||||
var bitcoind = new BitcoinService(baseConfig);
|
var bitcoind = new BitcoinService(baseConfig);
|
||||||
bitcoind._reindexWait = 1;
|
bitcoind._reindexWait = 1;
|
||||||
var node = {
|
var node = {
|
||||||
_reindex: true,
|
_reindex: true,
|
||||||
client: {
|
client: {
|
||||||
syncPercentage: sinon.stub().callsArgWith(0, {code: -1 , message: 'Test error'})
|
getBlockchainInfo: sinon.stub().callsArgWith(0, {code: -1 , message: 'Test error'})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
bitcoind._checkReindex(node, function(err) {
|
bitcoind._checkReindex(node, function(err) {
|
||||||
@ -743,15 +743,20 @@ describe('Bitcoin Service', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('will wait until syncpercentage is 100 percent', function(done) {
|
it('will wait until sync is 100 percent', function(done) {
|
||||||
var bitcoind = new BitcoinService(baseConfig);
|
var bitcoind = new BitcoinService(baseConfig);
|
||||||
bitcoind._reindexWait = 1;
|
bitcoind._reindexWait = 1;
|
||||||
var percent = 90;
|
var percent = 0.89;
|
||||||
var node = {
|
var node = {
|
||||||
_reindex: true,
|
_reindex: true,
|
||||||
client: {
|
client: {
|
||||||
syncPercentage: function(callback) {
|
getBlockchainInfo: function(callback) {
|
||||||
callback(null, percent++);
|
percent += 0.01;
|
||||||
|
callback(null, {
|
||||||
|
result: {
|
||||||
|
verificationprogress: percent
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user