Merge pull request #186 from mempool/simon/update-pricefeed

Replace opennode usd price source with wiz api.
This commit is contained in:
wiz 2020-11-23 16:06:15 +09:00 committed by GitHub
commit fdf9cf7977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View File

@ -2,10 +2,8 @@ import logger from '../logger';
import axios from 'axios';
class FiatConversion {
private tickers = {
'BTCUSD': {
'USD': 4110.78
},
private conversionRates = {
'USD': 0
};
constructor() { }
@ -16,16 +14,19 @@ class FiatConversion {
this.updateCurrency();
}
public getTickers() {
return this.tickers;
public getConversionRates() {
return this.conversionRates;
}
private async updateCurrency(): Promise<void> {
try {
const response = await axios.get('https://api.opennode.co/v1/rates');
this.tickers = response.data.data;
const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices');
const usd = response.data.data.find((item: any) => item.currencyCode === 'USD');
this.conversionRates = {
'USD': usd.price,
};
} catch (e) {
logger.err('Error updating currency from OpenNode: ' + e);
logger.err('Error updating fiat conversion rates: ' + e);
}
}
}

View File

@ -126,7 +126,7 @@ class WebsocketHandler {
'vBytesPerSecond': memPool.getVBytesPerSecond(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'blocks': _blocks,
'conversions': fiatConversion.getTickers()['BTCUSD'],
'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(),
'git-commit': backendInfo.gitCommitHash,