Modify /bisq/api/v1/markets/markets to only return active markets
As per https://github.com/bisq-network/bisq/issues/4826 and https://github.com/bisq-network/bisq/pull/4831
This commit is contained in:
parent
824bc21035
commit
d613aec395
@ -6,6 +6,8 @@ import * as datetime from 'locutus/php/datetime';
|
|||||||
class BisqMarketsApi {
|
class BisqMarketsApi {
|
||||||
private cryptoCurrencyData: Currency[] = [];
|
private cryptoCurrencyData: Currency[] = [];
|
||||||
private fiatCurrencyData: Currency[] = [];
|
private fiatCurrencyData: Currency[] = [];
|
||||||
|
private activeCryptoCurrencyData: Currency[] = [];
|
||||||
|
private activeFiatCurrencyData: Currency[] = [];
|
||||||
private offersData: OffersData[] = [];
|
private offersData: OffersData[] = [];
|
||||||
private tradesData: TradesData[] = [];
|
private tradesData: TradesData[] = [];
|
||||||
private fiatCurrenciesIndexed: { [code: string]: true } = {};
|
private fiatCurrenciesIndexed: { [code: string]: true } = {};
|
||||||
@ -32,9 +34,11 @@ class BisqMarketsApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrencyData(cryptoCurrency: Currency[], fiatCurrency: Currency[]) {
|
setCurrencyData(cryptoCurrency: Currency[], fiatCurrency: Currency[], activeCryptoCurrency: Currency[], activeFiatCurrency: Currency[]) {
|
||||||
this.cryptoCurrencyData = cryptoCurrency,
|
this.cryptoCurrencyData = cryptoCurrency,
|
||||||
this.fiatCurrencyData = fiatCurrency;
|
this.fiatCurrencyData = fiatCurrency,
|
||||||
|
this.activeCryptoCurrencyData = activeCryptoCurrency,
|
||||||
|
this.activeFiatCurrencyData = activeFiatCurrency;
|
||||||
|
|
||||||
this.fiatCurrenciesIndexed = {};
|
this.fiatCurrenciesIndexed = {};
|
||||||
this.allCurrenciesIndexed = {};
|
this.allCurrenciesIndexed = {};
|
||||||
@ -56,7 +60,7 @@ class BisqMarketsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrencies(
|
getCurrencies(
|
||||||
type: 'crypto' | 'fiat' | 'all' = 'all',
|
type: 'crypto' | 'fiat' | 'active' | 'all' = 'all',
|
||||||
): Currencies {
|
): Currencies {
|
||||||
let currencies: Currency[];
|
let currencies: Currency[];
|
||||||
|
|
||||||
@ -67,6 +71,9 @@ class BisqMarketsApi {
|
|||||||
case 'crypto':
|
case 'crypto':
|
||||||
currencies = this.cryptoCurrencyData;
|
currencies = this.cryptoCurrencyData;
|
||||||
break;
|
break;
|
||||||
|
case 'active':
|
||||||
|
currencies = this.activeCryptoCurrencyData.concat(this.activeFiatCurrencyData);
|
||||||
|
break;
|
||||||
case 'all':
|
case 'all':
|
||||||
default:
|
default:
|
||||||
currencies = this.cryptoCurrencyData.concat(this.fiatCurrencyData);
|
currencies = this.cryptoCurrencyData.concat(this.fiatCurrencyData);
|
||||||
@ -136,9 +143,10 @@ class BisqMarketsApi {
|
|||||||
|
|
||||||
getMarkets(): Markets {
|
getMarkets(): Markets {
|
||||||
const allCurrencies = this.getCurrencies();
|
const allCurrencies = this.getCurrencies();
|
||||||
|
const activeCurrencies = this.getCurrencies('active');
|
||||||
const markets = {};
|
const markets = {};
|
||||||
|
|
||||||
for (const currency of Object.keys(allCurrencies)) {
|
for (const currency of Object.keys(activeCurrencies)) {
|
||||||
if (allCurrencies[currency].code === 'BTC') {
|
if (allCurrencies[currency].code === 'BTC') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ class Bisq {
|
|||||||
private static FOLDER_WATCH_CHANGE_DETECTION_DEBOUNCE = 4000;
|
private static FOLDER_WATCH_CHANGE_DETECTION_DEBOUNCE = 4000;
|
||||||
private static MARKET_JSON_PATH = config.BISQ_MARKETS.DATA_PATH;
|
private static MARKET_JSON_PATH = config.BISQ_MARKETS.DATA_PATH;
|
||||||
private static MARKET_JSON_FILE_PATHS = {
|
private static MARKET_JSON_FILE_PATHS = {
|
||||||
|
activeCryptoCurrency: '/active_crypto_currency_list.json',
|
||||||
|
activeFiatCurrency: '/active_fiat_currency_list.json',
|
||||||
cryptoCurrency: '/crypto_currency_list.json',
|
cryptoCurrency: '/crypto_currency_list.json',
|
||||||
fiatCurrency: '/fiat_currency_list.json',
|
fiatCurrency: '/fiat_currency_list.json',
|
||||||
offers: '/offers_statistics.json',
|
offers: '/offers_statistics.json',
|
||||||
@ -66,8 +68,10 @@ class Bisq {
|
|||||||
if (cryptoMtime > this.cryptoCurrencyLastMtime || fiatMtime > this.fiatCurrencyLastMtime) {
|
if (cryptoMtime > this.cryptoCurrencyLastMtime || fiatMtime > this.fiatCurrencyLastMtime) {
|
||||||
const cryptoCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency);
|
const cryptoCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.cryptoCurrency);
|
||||||
const fiatCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.fiatCurrency);
|
const fiatCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.fiatCurrency);
|
||||||
|
const activeCryptoCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.activeCryptoCurrency);
|
||||||
|
const activeFiatCurrencyData = await this.loadData<Currency[]>(Bisq.MARKET_JSON_FILE_PATHS.activeFiatCurrency);
|
||||||
logger.debug('Updating Bisq Market Currency Data');
|
logger.debug('Updating Bisq Market Currency Data');
|
||||||
bisqMarket.setCurrencyData(cryptoCurrencyData, fiatCurrencyData);
|
bisqMarket.setCurrencyData(cryptoCurrencyData, fiatCurrencyData, activeCryptoCurrencyData, activeFiatCurrencyData);
|
||||||
if (cryptoMtime > this.cryptoCurrencyLastMtime) {
|
if (cryptoMtime > this.cryptoCurrencyLastMtime) {
|
||||||
this.cryptoCurrencyLastMtime = cryptoMtime;
|
this.cryptoCurrencyLastMtime = cryptoMtime;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user