mirror of
https://github.com/mempool/mempool.git
synced 2025-01-17 18:52:34 +01:00
parent
30fb0bad78
commit
1521d47cc7
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,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,
|
||||
|
Loading…
Reference in New Issue
Block a user