@@ -43,6 +43,7 @@ import (
4343	ethcatalyst "github.com/ethereum/go-ethereum/eth/catalyst" 
4444	"github.com/ethereum/go-ethereum/eth/downloader" 
4545	"github.com/ethereum/go-ethereum/eth/ethconfig" 
46+ 	"github.com/ethereum/go-ethereum/eth/filters" 
4647	"github.com/ethereum/go-ethereum/eth/gasprice" 
4748	"github.com/ethereum/go-ethereum/eth/tracers" 
4849	"github.com/ethereum/go-ethereum/ethdb" 
@@ -64,6 +65,7 @@ import (
6465	"github.com/ethereum/go-ethereum/p2p/nat" 
6566	"github.com/ethereum/go-ethereum/p2p/netutil" 
6667	"github.com/ethereum/go-ethereum/params" 
68+ 	"github.com/ethereum/go-ethereum/rpc" 
6769	pcsclite "github.com/gballet/go-libpcsclite" 
6870	gopsutil "github.com/shirou/gopsutil/mem" 
6971	"github.com/urfave/cli/v2" 
@@ -491,6 +493,12 @@ var (
491493		Usage :    "Enable recording the SHA3/keccak preimages of trie keys" ,
492494		Category : flags .PerfCategory ,
493495	}
496+ 	CacheLogSizeFlag  =  & cli.IntFlag {
497+ 		Name :     "cache.blocklogs" ,
498+ 		Usage :    "Size (in number of blocks) of the log cache for filtering" ,
499+ 		Category : flags .PerfCategory ,
500+ 		Value :    ethconfig .Defaults .FilterLogCacheSize ,
501+ 	}
494502	FDLimitFlag  =  & cli.IntFlag {
495503		Name :     "fdlimit" ,
496504		Usage :    "Raise the open file descriptor resource limit (default = system fd limit)" ,
@@ -1808,6 +1816,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18081816	if  ctx .IsSet (CacheFlag .Name ) ||  ctx .IsSet (CacheSnapshotFlag .Name ) {
18091817		cfg .SnapshotCache  =  ctx .Int (CacheFlag .Name ) *  ctx .Int (CacheSnapshotFlag .Name ) /  100 
18101818	}
1819+ 	if  ctx .IsSet (CacheLogSizeFlag .Name ) {
1820+ 		cfg .FilterLogCacheSize  =  ctx .Int (CacheLogSizeFlag .Name )
1821+ 	}
18111822	if  ! ctx .Bool (SnapshotFlag .Name ) {
18121823		// If snap-sync is requested, this flag is also required 
18131824		if  cfg .SyncMode  ==  downloader .SnapSync  {
@@ -2005,21 +2016,34 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
20052016	return  backend .APIBackend , backend 
20062017}
20072018
2008- // RegisterEthStatsService configures the Ethereum Stats daemon and adds it to 
2009- // the given node. 
2019+ // RegisterEthStatsService configures the Ethereum Stats daemon and adds it to the node. 
20102020func  RegisterEthStatsService (stack  * node.Node , backend  ethapi.Backend , url  string ) {
20112021	if  err  :=  ethstats .New (stack , backend , backend .Engine (), url ); err  !=  nil  {
20122022		Fatalf ("Failed to register the Ethereum Stats service: %v" , err )
20132023	}
20142024}
20152025
2016- // RegisterGraphQLService is a utility function to construct a new service and register it against a node. 
2017- func  RegisterGraphQLService (stack  * node.Node , backend  ethapi.Backend , cfg  node.Config ) {
2018- 	if  err  :=  graphql .New (stack , backend , cfg .GraphQLCors , cfg .GraphQLVirtualHosts ); err  !=  nil  {
2026+ // RegisterGraphQLService adds the GraphQL API to the node. 
2027+ func  RegisterGraphQLService (stack  * node.Node , backend  ethapi.Backend , filterSystem  * filters.FilterSystem , cfg  * node.Config ) {
2028+ 	err  :=  graphql .New (stack , backend , filterSystem , cfg .GraphQLCors , cfg .GraphQLVirtualHosts )
2029+ 	if  err  !=  nil  {
20192030		Fatalf ("Failed to register the GraphQL service: %v" , err )
20202031	}
20212032}
20222033
2034+ // RegisterFilterAPI adds the eth log filtering RPC API to the node. 
2035+ func  RegisterFilterAPI (stack  * node.Node , backend  ethapi.Backend , ethcfg  * ethconfig.Config ) * filters.FilterSystem  {
2036+ 	isLightClient  :=  ethcfg .SyncMode  ==  downloader .LightSync 
2037+ 	filterSystem  :=  filters .NewFilterSystem (backend , filters.Config {
2038+ 		LogCacheSize : ethcfg .FilterLogCacheSize ,
2039+ 	})
2040+ 	stack .RegisterAPIs ([]rpc.API {{
2041+ 		Namespace : "eth" ,
2042+ 		Service :   filters .NewFilterAPI (filterSystem , isLightClient ),
2043+ 	}})
2044+ 	return  filterSystem 
2045+ }
2046+ 
20232047func  SetupMetrics (ctx  * cli.Context ) {
20242048	if  metrics .Enabled  {
20252049		log .Info ("Enabling metrics collection" )
0 commit comments