File tree 2 files changed +24
-21
lines changed
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");
5
5
const { nodeCache } = require ( "../client/cache" ) ;
6
6
const db = require ( "../client/mongo" ) ;
7
7
const { Sentry } = require ( "../sentry" ) ;
8
- const { NODE_LOCATIONS } = require ( "../constants" ) ;
8
+ const { NODE_LOCATIONS , EXPIRE_48H } = require ( "../constants" ) ;
9
9
10
10
const NODE_IP_REGEX = / \[ : : f f f f : ( [ \d . ] + ) \] : [ \d ] + / ;
11
11
@@ -73,8 +73,11 @@ const getNodeLocation = async ip => {
73
73
74
74
const doNodeLocations = async ( ) => {
75
75
console . log ( "Starting doNodeLocations" ) ;
76
-
76
+ const nodeLocations = nodeCache . get ( NODE_LOCATIONS ) ;
77
77
try {
78
+ if ( nodeLocations ) {
79
+ return nodeLocations ;
80
+ }
78
81
let peers = await getNodePeers ( ) ;
79
82
let results = [ ] ;
80
83
@@ -106,7 +109,7 @@ const doNodeLocations = async () => {
106
109
await database . collection ( NODE_LOCATIONS ) . deleteMany ( { } ) ;
107
110
await database . collection ( NODE_LOCATIONS ) . insertMany ( results ) ;
108
111
109
- nodeCache . set ( NODE_LOCATIONS , results ) ;
112
+ nodeCache . set ( NODE_LOCATIONS , results , EXPIRE_48H ) ;
110
113
111
114
console . log ( "Done node location" ) ;
112
115
} catch ( err ) {
Original file line number Diff line number Diff line change @@ -30,25 +30,25 @@ const allowedRpcMethods = [
30
30
"uptime" ,
31
31
"version" ,
32
32
] ;
33
-
33
+ // @Note more cache due to 26.1
34
34
const 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 ,
52
52
uptime : 30 ,
53
53
version : 30 ,
54
54
} ;
You can’t perform that action at this time.
0 commit comments