diff --git a/server/cron/nodeLocations.js b/server/cron/nodeLocations.js index a13f3fcd..2eef409b 100644 --- a/server/cron/nodeLocations.js +++ b/server/cron/nodeLocations.js @@ -5,7 +5,7 @@ const { rpc } = require("../rpc"); const { nodeCache } = require("../client/cache"); const db = require("../client/mongo"); const { Sentry } = require("../sentry"); -const { NODE_LOCATIONS } = require("../constants"); +const { NODE_LOCATIONS, EXPIRE_48H } = require("../constants"); const NODE_IP_REGEX = /\[::ffff:([\d.]+)\]:[\d]+/; @@ -73,8 +73,11 @@ const getNodeLocation = async ip => { const doNodeLocations = async () => { console.log("Starting doNodeLocations"); - + const nodeLocations = nodeCache.get(NODE_LOCATIONS); try { + if (nodeLocations) { + return nodeLocations; + } let peers = await getNodePeers(); let results = []; @@ -106,7 +109,7 @@ const doNodeLocations = async () => { await database.collection(NODE_LOCATIONS).deleteMany({}); await database.collection(NODE_LOCATIONS).insertMany(results); - nodeCache.set(NODE_LOCATIONS, results); + nodeCache.set(NODE_LOCATIONS, results, EXPIRE_48H); console.log("Done node location"); } catch (err) { diff --git a/server/rpc/index.js b/server/rpc/index.js index 183b5586..9913f309 100644 --- a/server/rpc/index.js +++ b/server/rpc/index.js @@ -30,25 +30,25 @@ const allowedRpcMethods = [ "uptime", "version", ]; - +//@Note more cache due to 26.1 const cacheSettings = { - account_history: 1, - account_info: 1, - account_representative: 5, - accounts_balances: 1, - active_difficulty: 1, - available_supply: 3600, - block_count: 1, - block_info: 1, - blocks_info: 5, - confirmation_history: 5, - confirmation_quorum: 5, - frontier_count: 5, - peers: 5, - pending: 5, - representatives: 5, - representatives_online: 5, - stats: 5, + account_history: 1000, + account_info: 1000, + account_representative: 3600, + accounts_balances: 100, + active_difficulty: 100, + available_supply: 3600 * 10, + block_count: 100, + block_info: 100, + blocks_info: 500, + confirmation_history: 500, + confirmation_quorum: 500, + frontier_count: 500, + peers: 3600, + pending: 500, + representatives: 3600 * 4, + representatives_online: 3600 * 4, + stats: 500, uptime: 30, version: 30, };