@@ -27,14 +27,14 @@ import (
2727
2828 ethereum "github.com/XinFinOrg/XDPoSChain"
2929 "github.com/XinFinOrg/XDPoSChain/common"
30+ "github.com/XinFinOrg/XDPoSChain/common/lru"
3031 "github.com/XinFinOrg/XDPoSChain/core"
3132 "github.com/XinFinOrg/XDPoSChain/core/bloombits"
3233 "github.com/XinFinOrg/XDPoSChain/core/types"
3334 "github.com/XinFinOrg/XDPoSChain/ethdb"
3435 "github.com/XinFinOrg/XDPoSChain/event"
3536 "github.com/XinFinOrg/XDPoSChain/log"
3637 "github.com/XinFinOrg/XDPoSChain/rpc"
37- lru "github.com/hashicorp/golang-lru"
3838)
3939
4040// Config represents the configuration of the filter system.
@@ -74,21 +74,16 @@ type Backend interface {
7474// FilterSystem holds resources shared by all filters.
7575type FilterSystem struct {
7676 backend Backend
77- logsCache * lru.Cache
77+ logsCache * lru.Cache [common. Hash , [][] * types. Log ]
7878 cfg * Config
7979}
8080
8181// NewFilterSystem creates a filter system.
8282func NewFilterSystem (backend Backend , config Config ) * FilterSystem {
8383 config = config .withDefaults ()
84-
85- cache , err := lru .New (config .LogCacheSize )
86- if err != nil {
87- panic (err )
88- }
8984 return & FilterSystem {
9085 backend : backend ,
91- logsCache : cache ,
86+ logsCache : lru. NewCache [common. Hash , [][] * types. Log ]( config . LogCacheSize ) ,
9287 cfg : & config ,
9388 }
9489}
@@ -97,7 +92,7 @@ func NewFilterSystem(backend Backend, config Config) *FilterSystem {
9792func (sys * FilterSystem ) cachedGetLogs (ctx context.Context , blockHash common.Hash , number uint64 ) ([][]* types.Log , error ) {
9893 cached , ok := sys .logsCache .Get (blockHash )
9994 if ok {
100- return cached .([][] * types. Log ) , nil
95+ return cached , nil
10196 }
10297
10398 logs , err := sys .backend .GetLogs (ctx , blockHash , number )
0 commit comments