fixed missing bch rates in rates service
This commit is contained in:
parent
8b1d2d7ab0
commit
7edf3d76ac
1 changed files with 5 additions and 11 deletions
|
|
@ -25,7 +25,7 @@ var RateService = function(opts) {
|
||||||
self._isAvailable = false;
|
self._isAvailable = false;
|
||||||
self._rates = {};
|
self._rates = {};
|
||||||
self._alternatives = [];
|
self._alternatives = [];
|
||||||
self._ratesBCH = {};
|
self._bchRate = null;
|
||||||
self._queued = [];
|
self._queued = [];
|
||||||
|
|
||||||
self.updateRates();
|
self.updateRates();
|
||||||
|
|
@ -46,7 +46,7 @@ RateService.prototype.updateRates = function() {
|
||||||
var backoffSeconds = 5;
|
var backoffSeconds = 5;
|
||||||
var updateFrequencySeconds = 5 * 60;
|
var updateFrequencySeconds = 5 * 60;
|
||||||
var rateServiceUrl = 'https://bitpay.com/api/rates';
|
var rateServiceUrl = 'https://bitpay.com/api/rates';
|
||||||
var bchRateServiceUrl = 'https://api.kraken.com/0/public/Ticker?pair=BCHUSD,BCHEUR';
|
var bchRateServiceUrl = 'https://www.bitcoin.com/special/rates.json';
|
||||||
|
|
||||||
|
|
||||||
function getBTC(cb, tries) {
|
function getBTC(cb, tries) {
|
||||||
|
|
@ -91,11 +91,7 @@ RateService.prototype.updateRates = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.httprequest.get(bchRateServiceUrl).success(function(res) {
|
self.httprequest.get(bchRateServiceUrl).success(function(res) {
|
||||||
self.lodash.each(res.result, function(data, paircode) {
|
self._bchRate = self.lodash.find(res, function(c) { return c.code == 'BCH'; }).rate;
|
||||||
var code = paircode.substr(3,3);
|
|
||||||
var rate =data.c[0];
|
|
||||||
self._ratesBCH[code] = rate;
|
|
||||||
})
|
|
||||||
return cb();
|
return cb();
|
||||||
}).error(function() {
|
}).error(function() {
|
||||||
return retry(tries);
|
return retry(tries);
|
||||||
|
|
@ -118,10 +114,8 @@ RateService.prototype.updateRates = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
RateService.prototype.getRate = function(code, chain) {
|
RateService.prototype.getRate = function(code, chain) {
|
||||||
if (chain == 'bch')
|
var rate = this._rates[code];
|
||||||
return this._ratesBCH[code];
|
return chain == 'bch' ? this._bchRate * rate : rate;
|
||||||
else
|
|
||||||
return this._rates[code];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RateService.prototype.getAlternatives = function() {
|
RateService.prototype.getAlternatives = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue