add derivation delay

This commit is contained in:
Ivan Socolsky 2015-04-01 17:21:06 -03:00
parent cdd1e9ea58
commit 9ad89452cb
2 changed files with 8 additions and 4 deletions

View File

@ -1045,7 +1045,8 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
WalletService.scanConfig = {
SCAN_WINDOW: 10,
SCAN_WINDOW: 20,
DERIVATION_DELAY: 10, // in milliseconds
};
/**
@ -1063,7 +1064,9 @@ WalletService.prototype.scan = function(opts, cb) {
function deriveAddresses(size, isChange, derivator, cb) {
async.map(_.range(size), function(i, next) {
next(null, derivator(isChange));
setTimeout(function() {
next(null, derivator(isChange));
}, WalletService.scanConfig.DERIVATION_DELAY)
}, cb);
};

View File

@ -2481,12 +2481,13 @@ describe('Wallet service', function() {
});
describe('#scan', function() {
var scanWindowOld = WalletService.scanConfig.SCAN_WINDOW;
var scanConfigOld = WalletService.scanConfig;
beforeEach(function() {
WalletService.scanConfig.SCAN_WINDOW = 2;
WalletService.scanConfig.DERIVATION_DELAY = 0;
});
afterEach(function() {
WalletService.scanConfig.SCAN_WINDOW = scanWindowOld;
WalletService.scanConfig = scanConfigOld;
});
it('should scan main addresses', function(done) {