Browse Source

add lock

feat/2-step-opt
Matias Alejo Garcia 7 years ago
parent
commit
3a75b38232
No known key found for this signature in database GPG Key ID: 2470DB551277AB3
  1. 3
      lib/server.js

3
lib/server.js

@ -1277,6 +1277,8 @@ WalletService.prototype._getBalanceFromAddresses = function(opts, cb) {
WalletService.prototype._getBalanceOneStep = function(opts, cb) { WalletService.prototype._getBalanceOneStep = function(opts, cb) {
var self = this; var self = this;
// This lock is to prevent server starvation on big wallets
self._runLocked(cb, function(cb) {
self.storage.fetchAddresses(self.walletId, function(err, addresses) { self.storage.fetchAddresses(self.walletId, function(err, addresses) {
if (err) return cb(err); if (err) return cb(err);
self._getBalanceFromAddresses({ self._getBalanceFromAddresses({
@ -1295,6 +1297,7 @@ WalletService.prototype._getBalanceOneStep = function(opts, cb) {
}); });
}); });
}); });
});
}; };

Loading…
Cancel
Save