mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 02:35:09 +02:00
Added config option to disable CMC
This commit is contained in:
parent
3c31a2daa3
commit
3f1a6ef445
12
README.md
12
README.md
@ -150,11 +150,13 @@ Set configuration variables
|
||||
- `API_L2_HTTP` should be edited to the HTTP url of a L2 ethereum node
|
||||
- `API_L2_WS` should be edited to the WS url of an Arbitrum mainnet Alchemy node
|
||||
- `CONF_DEFAULT_ORCH` should be edited to the public address of your own Orchestrator. This is the default Orchestrator the backend will return
|
||||
- 'CONF_SIMPLE_MODE' if set to true, will disable live smart contract monitoring. Also disabled all MONGO related functionalities. Config flags 'API_L2_WS', 'MONGO_URI', 'MONGO_URI_DEV' and 'MONGO_URI_LOCAL' can be ignored if this flag is set to true.
|
||||
- 'CONF_TIMEOUT_CMC' time in milliseconds of how long coinmarketcap data is kept in the cache before a new request is made. Recommended is around 5-6 minutes in order to stay below the default daily soft cap
|
||||
- 'CONF_TIMEOUT_ALCHEMY' time in milliseconds of how long blockchain information, like gas prices, is being kept in the cache
|
||||
- 'CONF_TIMEOUT_LIVEPEER' time in milliseconds of how long livepeer data, like orchestrator and delegator information, is being kept in the cache
|
||||
|
||||
- `CONF_SIMPLE_MODE` if set to true, will disable live smart contract monitoring. Also disabled all MONGO related functionalities. Config flags `API_L2_WS`, `MONGO_URI`, `MONGO_URI_DEV` and `MONGO_URI_LOCAL` can be ignored if this flag is set to true.
|
||||
- `CONF_TIMEOUT_CMC` time in milliseconds of how long coinmarketcap data is kept in the cache before a new request is made. Recommended is around 5-6 minutes in order to stay below the default daily soft cap
|
||||
- `CONF_TIMEOUT_ALCHEMY` time in milliseconds of how long blockchain information, like gas prices, is being kept in the cache
|
||||
- `CONF_TIMEOUT_LIVEPEER` time in milliseconds of how long livepeer data, like orchestrator and delegator information, is being kept in the cache
|
||||
- `CONF_DISABLE_SYNC` set to true to disable syncing events and tickets at boot
|
||||
- `CONF_DISABLE_DB` set to false to disable persistent storage of events and tickets into a mongodb database
|
||||
- `CONF_DISABLE_CMC` set to false to disable coin quotes using CMC
|
||||
## Developing
|
||||
Open the directory of your backend and run
|
||||
- `npm run dev`
|
||||
|
@ -18,5 +18,6 @@ export const {
|
||||
CONF_TIMEOUT_ALCHEMY = 2000,
|
||||
CONF_TIMEOUT_LIVEPEER = 60000,
|
||||
CONF_DISABLE_SYNC = false,
|
||||
CONF_DISABLE_DB = false
|
||||
CONF_DISABLE_DB = false,
|
||||
CONF_DISABLE_CMC = false
|
||||
} = process.env;
|
||||
|
@ -8,7 +8,8 @@ import {
|
||||
API_CMC, API_L1_HTTP, API_L2_HTTP, API_L2_WS,
|
||||
CONF_DEFAULT_ORCH, CONF_SIMPLE_MODE, CONF_TIMEOUT_CMC,
|
||||
CONF_TIMEOUT_ALCHEMY, CONF_TIMEOUT_LIVEPEER, CONF_DISABLE_SYNC,
|
||||
CONF_DISABLE_DB
|
||||
CONF_DISABLE_DB,
|
||||
CONF_DISABLE_CMC
|
||||
} from "../config";
|
||||
// Do API requests to other API's
|
||||
const https = require('https');
|
||||
@ -17,8 +18,20 @@ const fs = require('fs');
|
||||
// Used for the livepeer thegraph API
|
||||
import { request, gql } from 'graphql-request';
|
||||
// Gets ETH, LPT and other coin info
|
||||
const CoinMarketCap = require('coinmarketcap-api');
|
||||
const cmcClient = new CoinMarketCap(API_CMC);
|
||||
let CoinMarketCap = require('coinmarketcap-api');
|
||||
let cmcClient = new CoinMarketCap(API_CMC);
|
||||
let cmcEnabled = false;
|
||||
if(!CONF_DISABLE_CMC){
|
||||
if(API_CMC == ""){
|
||||
console.log("Please provide a CMC api key");
|
||||
}else {
|
||||
CoinMarketCap = require('coinmarketcap-api');
|
||||
cmcClient = new CoinMarketCap(API_CMC);
|
||||
cmcEnabled = true;
|
||||
}
|
||||
}else{
|
||||
console.log("Running without CMC api");
|
||||
}
|
||||
// Gets blockchain data
|
||||
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
|
||||
// Gets gas prices
|
||||
@ -395,6 +408,9 @@ if (!isEventSyncing && !CONF_SIMPLE_MODE && !CONF_DISABLE_SYNC) {
|
||||
// Splits of raw CMC object into coin quote data
|
||||
const parseCmc = async function () {
|
||||
try {
|
||||
if (!cmcEnabled){
|
||||
return;
|
||||
}
|
||||
cmcCache = await cmcClient.getTickers({ limit: 200 });
|
||||
for (var idx = 0; idx < cmcCache.data.length; idx++) {
|
||||
const coinData = cmcCache.data[idx];
|
||||
|
@ -232,7 +232,7 @@ const EventViewer = (obj) => {
|
||||
filterBit =
|
||||
<div className="strokeSmollLeft roundedOpaque" style={{ borderTopLeftRadius: 0, borderTopRightRadius: 0, borderBottomLeftRadius: 0, margin: 0, width: '100%' }}>
|
||||
<div className="row">
|
||||
<span>Showing {filtered + unfiltered} out of {limitShown} results</span>
|
||||
<span>Showing {hidden + unfiltered} out of {limitShown} results</span>
|
||||
</div>
|
||||
<div className="flexContainer" style={{margin: 0, width: '100%'}}>
|
||||
<div className="strokeSmollLeft" style={{ margin: 0, padding: 0, flex: 2 }}>
|
||||
@ -311,7 +311,7 @@ const EventViewer = (obj) => {
|
||||
</div>
|
||||
</ScrollContainer>
|
||||
<div className="strokeSmollLeft" style={{ marginRight: "1em" }}>
|
||||
<button className={filterActivated ? "row nonHomeButton active" : "row nonHomeButton"} style={{ backgroundColor: filterActivatedColour }} onClick={() => {
|
||||
<button className={filterActivated ? "row nonHomeButton active" : "row nonHomeButton"} style={{ backgroundColor: filterActivatedColour, marginTop: '0.7em' }} onClick={() => {
|
||||
setFilterActivated(!filterActivated);
|
||||
}}>
|
||||
<h3>Activated</h3>
|
||||
|
Loading…
x
Reference in New Issue
Block a user