Add optional callback to pollBalance

This commit is contained in:
Maciej Małecki 2014-04-16 10:01:31 +02:00
parent 926e10da01
commit 5b53d59cba

View file

@ -155,7 +155,7 @@ Trader.prototype.stopPolling = function () {
clearInterval(this.rateInterval);
};
Trader.prototype.pollBalance = function () {
Trader.prototype.pollBalance = function (callback) {
var self = this;
self.logger.info('collecting balance');
@ -170,9 +170,15 @@ Trader.prototype.pollBalance = function () {
self.tradeExchange.balance(next);
}
}, function (err, balance) {
if (err) {
return callback && callback(err);
}
balance.timestamp = Date.now();
self.logger.info('Balance update:', balance);
self.balance = balance;
callback && callback(null, balance);
});
};