@@ -112,10 +112,11 @@ public enum RequestSource {
112112
113113 private static final String FILTER_NOT_FOUND = "filter not found" ;
114114 public static final int EXPIRE_SECONDS = 5 * 60 ;
115- private static final Cache <Integer , LogFilterElement > logElementCache = CacheBuilder .newBuilder ()
116- .maximumSize (300_000L ) // 300s * tps(1000) * 1 log/tx ≈ 300_000
117- .expireAfterWrite (EXPIRE_SECONDS , TimeUnit .SECONDS )
118- .recordStats ().build (); //LRU cache
115+ private static final Cache <LogFilterElement , LogFilterElement > logElementCache =
116+ CacheBuilder .newBuilder ()
117+ .maximumSize (300_000L ) // 300s * tps(1000) * 1 log/tx ≈ 300_000
118+ .expireAfterWrite (EXPIRE_SECONDS , TimeUnit .SECONDS )
119+ .recordStats ().build (); //LRU cache
119120 /**
120121 * for log filter in Full Json-RPC
121122 */
@@ -171,7 +172,7 @@ public enum RequestSource {
171172
172173 @ Autowired
173174 public TronJsonRpcImpl (@ Autowired NodeInfoService nodeInfoService , @ Autowired Wallet wallet ,
174- @ Autowired Manager manager ) {
175+ @ Autowired Manager manager ) {
175176 this .nodeInfoService = nodeInfoService ;
176177 this .wallet = wallet ;
177178 this .manager = manager ;
@@ -239,8 +240,10 @@ public static void handleLogsFilter(LogsFilterCapsule logsFilterCapsule) {
239240 for (LogFilterElement element : elements ) {
240241 LogFilterElement newElement ;
241242 try {
242- newElement = logElementCache .get (element .hashCode (), () -> element );
243+ //compare with hashcode() first, then with equals(). If not exist, put it.
244+ newElement = logElementCache .get (element , () -> element );
243245 } catch (ExecutionException e ) {
246+ logger .error ("Getting/loading LogFilterElement from cache fails" , e );//never happen
244247 continue ;
245248 }
246249 logFilterAndResult .getResult ().add (newElement );
0 commit comments