configurable price update frequency

This commit is contained in:
Mononaut 2023-07-29 14:45:00 +09:00 committed by softsimon
parent 22665f149b
commit 09c23b1241
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
8 changed files with 13 additions and 2 deletions

View File

@ -116,6 +116,7 @@
"PASSWORD": ""
},
"PRICE_DATA_SERVER": {
"UPDATE_FREQUENCY": 300,
"TOR_URL": "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices",
"CLEARNET_URL": "https://price.bisq.wiz.biz/getAllMarketPrices"
},

View File

@ -93,6 +93,7 @@
"PASSWORD": "__SOCKS5PROXY_PASSWORD__"
},
"PRICE_DATA_SERVER": {
"UPDATE_FREQUENCY": "__PRICE_DATA_SERVER_UPDATE_FREQUENCY",
"TOR_URL": "__PRICE_DATA_SERVER_TOR_URL__",
"CLEARNET_URL": "__PRICE_DATA_SERVER_CLEARNET_URL__"
},

View File

@ -102,6 +102,7 @@ describe('Mempool Backend Config', () => {
});
expect(config.PRICE_DATA_SERVER).toStrictEqual({
UPDATE_FREQUENCY: 3600,
TOR_URL: 'http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices',
CLEARNET_URL: 'https://price.bisq.wiz.biz/getAllMarketPrices'
});

View File

@ -116,6 +116,7 @@ interface IConfig {
PASSWORD: string;
};
PRICE_DATA_SERVER: {
UPDATE_FREQUENCY: number;
TOR_URL: string;
CLEARNET_URL: string;
};
@ -259,6 +260,7 @@ const defaults: IConfig = {
'PASSWORD': ''
},
'PRICE_DATA_SERVER': {
'UPDATE_FREQUENCY': 3600,
'TOR_URL': 'http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices',
'CLEARNET_URL': 'https://price.bisq.wiz.biz/getAllMarketPrices'
},

View File

@ -108,8 +108,8 @@ class PriceUpdater {
this.lastRun = await PricesRepository.$getLatestPriceTime();
}
if ((Math.round(new Date().getTime() / 1000) - this.lastRun) < 3600) {
// Refresh only once every hour
if ((Math.round(new Date().getTime() / 1000) - this.lastRun) < config.PRICE_DATA_SERVER.UPDATE_FREQUENCY) {
// Refresh every UPDATE_FREQUENCY seconds at most
return;
}

View File

@ -112,6 +112,7 @@
"PASSWORD": "__SOCKS5PROXY_PASSWORD__"
},
"PRICE_DATA_SERVER": {
"UPDATE_FREQUENCY": "__PRICE_DATA_SERVER_UPDATE_FREQUENCY__",
"TOR_URL": "__PRICE_DATA_SERVER_TOR_URL__",
"CLEARNET_URL": "__PRICE_DATA_SERVER_CLEARNET_URL__"
},

View File

@ -95,6 +95,7 @@ __SOCKS5PROXY_USERNAME__=${SOCKS5PROXY_USERNAME:=""}
__SOCKS5PROXY_PASSWORD__=${SOCKS5PROXY_PASSWORD:=""}
# PRICE_DATA_SERVER
__PRICE_DATA_SERVER_UPDATE_FREQUENCY__=${PRICE_DATA_SERVER_UPDATE_FREQUENCY:=300}
__PRICE_DATA_SERVER_TOR_URL__=${PRICE_DATA_SERVER_TOR_URL:=http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/getAllMarketPrices}
__PRICE_DATA_SERVER_CLEARNET_URL__=${PRICE_DATA_SERVER_CLEARNET_URL:=https://price.bisq.wiz.biz/getAllMarketPrices}
@ -226,6 +227,7 @@ sed -i "s!__SOCKS5PROXY_PORT__!${__SOCKS5PROXY_PORT__}!g" mempool-config.json
sed -i "s!__SOCKS5PROXY_USERNAME__!${__SOCKS5PROXY_USERNAME__}!g" mempool-config.json
sed -i "s!__SOCKS5PROXY_PASSWORD__!${__SOCKS5PROXY_PASSWORD__}!g" mempool-config.json
sed -i "s!__PRICE_DATA_SERVER_UPDATE_FREQUENCY__!${__PRICE_DATA_SERVER_UPDATE_FREQUENCY__}!g" mempool-config.json
sed -i "s!__PRICE_DATA_SERVER_TOR_URL__!${__PRICE_DATA_SERVER_TOR_URL__}!g" mempool-config.json
sed -i "s!__PRICE_DATA_SERVER_CLEARNET_URL__!${__PRICE_DATA_SERVER_CLEARNET_URL__}!g" mempool-config.json

View File

@ -49,6 +49,9 @@
"ENABLED": true,
"TX_PER_SECOND_SAMPLE_PERIOD": 150
},
"PRICE_DATA_SERVER": {
"UPDATE_FREQUENCY": 300
},
"REPLICATION": {
"ENABLED": true,
"AUDIT": true,