File tree Expand file tree Collapse file tree 2 files changed +24
-21
lines changed Expand file tree Collapse file tree 2 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const { rpc } = require("../rpc");
55const { nodeCache } = require ( "../client/cache" ) ;
66const db = require ( "../client/mongo" ) ;
77const { Sentry } = require ( "../sentry" ) ;
8- const { NODE_LOCATIONS } = require ( "../constants" ) ;
8+ const { NODE_LOCATIONS , EXPIRE_48H } = require ( "../constants" ) ;
99
1010const NODE_IP_REGEX = / \[ : : f f f f : ( [ \d . ] + ) \] : [ \d ] + / ;
1111
@@ -73,8 +73,11 @@ const getNodeLocation = async ip => {
7373
7474const doNodeLocations = async ( ) => {
7575 console . log ( "Starting doNodeLocations" ) ;
76-
76+ const nodeLocations = nodeCache . get ( NODE_LOCATIONS ) ;
7777 try {
78+ if ( nodeLocations ) {
79+ return nodeLocations ;
80+ }
7881 let peers = await getNodePeers ( ) ;
7982 let results = [ ] ;
8083
@@ -106,7 +109,7 @@ const doNodeLocations = async () => {
106109 await database . collection ( NODE_LOCATIONS ) . deleteMany ( { } ) ;
107110 await database . collection ( NODE_LOCATIONS ) . insertMany ( results ) ;
108111
109- nodeCache . set ( NODE_LOCATIONS , results ) ;
112+ nodeCache . set ( NODE_LOCATIONS , results , EXPIRE_48H ) ;
110113
111114 console . log ( "Done node location" ) ;
112115 } catch ( err ) {
Original file line number Diff line number Diff line change @@ -30,25 +30,25 @@ const allowedRpcMethods = [
3030 "uptime" ,
3131 "version" ,
3232] ;
33-
33+ // @Note more cache due to 26.1
3434const cacheSettings = {
35- account_history : 1 ,
36- account_info : 1 ,
37- account_representative : 5 ,
38- accounts_balances : 1 ,
39- active_difficulty : 1 ,
40- available_supply : 3600 ,
41- block_count : 1 ,
42- block_info : 1 ,
43- blocks_info : 5 ,
44- confirmation_history : 5 ,
45- confirmation_quorum : 5 ,
46- frontier_count : 5 ,
47- peers : 5 ,
48- pending : 5 ,
49- representatives : 5 ,
50- representatives_online : 5 ,
51- stats : 5 ,
35+ account_history : 1000 ,
36+ account_info : 1000 ,
37+ account_representative : 3600 ,
38+ accounts_balances : 100 ,
39+ active_difficulty : 100 ,
40+ available_supply : 3600 * 10 ,
41+ block_count : 100 ,
42+ block_info : 100 ,
43+ blocks_info : 500 ,
44+ confirmation_history : 500 ,
45+ confirmation_quorum : 500 ,
46+ frontier_count : 500 ,
47+ peers : 3600 ,
48+ pending : 500 ,
49+ representatives : 3600 * 4 ,
50+ representatives_online : 3600 * 4 ,
51+ stats : 500 ,
5252 uptime : 30 ,
5353 version : 30 ,
5454} ;
You can’t perform that action at this time.
0 commit comments