Ivan Socolsky
9 years ago
No known key found for this signature in database
GPG Key ID: FAECE6A05FAA4F56
2 changed files with
17 additions and
5 deletions
-
lib/server.js
-
test/integration/server.js
|
|
@ -2448,16 +2448,28 @@ WalletService.prototype._normalizeTxHistory = function(txs) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService._cachedBlockheight = {}; |
|
|
|
WalletService._cachedBlockheight; |
|
|
|
|
|
|
|
WalletService._initBlockchainHeightCache = function() { |
|
|
|
if (WalletService._cachedBlockheight) return; |
|
|
|
WalletService._cachedBlockheight = { |
|
|
|
livenet: {}, |
|
|
|
testnet: {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService._clearBlockchainHeightCache = function() { |
|
|
|
WalletService._cachedBlockheight.current = null; |
|
|
|
WalletService._initBlockchainHeightCache(); |
|
|
|
WalletService._cachedBlockheight.livenet.current = null; |
|
|
|
WalletService._cachedBlockheight.testnet.current = null; |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService.prototype._getBlockchainHeight = function(network, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
var now = Date.now(); |
|
|
|
var cache = WalletService._cachedBlockheight; |
|
|
|
WalletService._initBlockchainHeightCache(); |
|
|
|
var cache = WalletService._cachedBlockheight[network]; |
|
|
|
|
|
|
|
function fetchFromBlockchain(cb) { |
|
|
|
var bc = self._getBlockchainExplorer(network); |
|
|
|
|
|
@ -5930,7 +5930,7 @@ describe('Wallet service', function() { |
|
|
|
it('should get real # of confirmations based on current block height', function(done) { |
|
|
|
var _confirmations = Defaults.CONFIRMATIONS_TO_START_CACHING; |
|
|
|
Defaults.CONFIRMATIONS_TO_START_CACHING = 6; |
|
|
|
WalletService._cachedBlockheight = {}; |
|
|
|
WalletService._cachedBlockheight = null; |
|
|
|
|
|
|
|
var h = helpers.historyCacheTest(20); |
|
|
|
_.each(h, function(x, i) { |
|
|
@ -5989,7 +5989,7 @@ describe('Wallet service', function() { |
|
|
|
it('should get cached # of confirmations if current height unknown', function(done) { |
|
|
|
var _confirmations = Defaults.CONFIRMATIONS_TO_START_CACHING; |
|
|
|
Defaults.CONFIRMATIONS_TO_START_CACHING = 6; |
|
|
|
WalletService._cachedBlockheight = {}; |
|
|
|
WalletService._cachedBlockheight = null; |
|
|
|
|
|
|
|
var h = helpers.historyCacheTest(20); |
|
|
|
helpers.stubHistory(h); |
|
|
|