mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 02:35:09 +02:00
Fix double CMC api calls being made and set the timeout to 6mins to stay under the hard cap this month
This commit is contained in:
parent
157c6677ea
commit
da4b365397
@ -23,7 +23,7 @@ const web3layer2 = createAlchemyWeb3(API_L2_HTTP);
|
||||
const web3layer2WS = createAlchemyWeb3(API_L2_WS);
|
||||
|
||||
// Update CoinMarketCap related api calls every 5 minutes
|
||||
const timeoutCMC = 300000;
|
||||
const timeoutCMC = 360000;
|
||||
let cmcPriceGet = 0;
|
||||
let ethPrice = 0;
|
||||
let lptPrice = 0;
|
||||
@ -334,8 +334,8 @@ apiRouter.get("/cmc", async (req, res) => {
|
||||
const now = new Date().getTime();
|
||||
// Update cmc once their data has expired
|
||||
if (now - cmcPriceGet > timeoutCMC) {
|
||||
await parseCmc();
|
||||
cmcPriceGet = now;
|
||||
await parseCmc();
|
||||
}
|
||||
res.send(cmcCache);
|
||||
} catch (err) {
|
||||
@ -349,8 +349,8 @@ apiRouter.get("/blockchains", async (req, res) => {
|
||||
const now = new Date().getTime();
|
||||
// Update blockchain data if the cached data has expired
|
||||
if (now - arbGet > timeoutAlchemy) {
|
||||
await parseEthBlockchain();
|
||||
arbGet = now;
|
||||
await parseEthBlockchain();
|
||||
}
|
||||
res.send({
|
||||
timestamp: now,
|
||||
@ -383,9 +383,8 @@ apiRouter.get("/quotes", async (req, res) => {
|
||||
const now = new Date().getTime();
|
||||
// Update cmc once their data has expired
|
||||
if (now - cmcPriceGet > timeoutCMC) {
|
||||
cmcCache = await cmcClient.getTickers({ limit: 200 });
|
||||
await parseCmc();
|
||||
cmcPriceGet = now;
|
||||
await parseCmc();
|
||||
}
|
||||
res.send(cmcQuotes);
|
||||
} catch (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user