@@ -43,6 +43,7 @@ import (
43
43
ethcatalyst "github.com/ethereum/go-ethereum/eth/catalyst"
44
44
"github.com/ethereum/go-ethereum/eth/downloader"
45
45
"github.com/ethereum/go-ethereum/eth/ethconfig"
46
+ "github.com/ethereum/go-ethereum/eth/filters"
46
47
"github.com/ethereum/go-ethereum/eth/gasprice"
47
48
"github.com/ethereum/go-ethereum/eth/tracers"
48
49
"github.com/ethereum/go-ethereum/ethdb"
@@ -64,6 +65,7 @@ import (
64
65
"github.com/ethereum/go-ethereum/p2p/nat"
65
66
"github.com/ethereum/go-ethereum/p2p/netutil"
66
67
"github.com/ethereum/go-ethereum/params"
68
+ "github.com/ethereum/go-ethereum/rpc"
67
69
pcsclite "github.com/gballet/go-libpcsclite"
68
70
gopsutil "github.com/shirou/gopsutil/mem"
69
71
"github.com/urfave/cli/v2"
@@ -491,6 +493,12 @@ var (
491
493
Usage : "Enable recording the SHA3/keccak preimages of trie keys" ,
492
494
Category : flags .PerfCategory ,
493
495
}
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
+ }
494
502
FDLimitFlag = & cli.IntFlag {
495
503
Name : "fdlimit" ,
496
504
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) {
1808
1816
if ctx .IsSet (CacheFlag .Name ) || ctx .IsSet (CacheSnapshotFlag .Name ) {
1809
1817
cfg .SnapshotCache = ctx .Int (CacheFlag .Name ) * ctx .Int (CacheSnapshotFlag .Name ) / 100
1810
1818
}
1819
+ if ctx .IsSet (CacheLogSizeFlag .Name ) {
1820
+ cfg .FilterLogCacheSize = ctx .Int (CacheLogSizeFlag .Name )
1821
+ }
1811
1822
if ! ctx .Bool (SnapshotFlag .Name ) {
1812
1823
// If snap-sync is requested, this flag is also required
1813
1824
if cfg .SyncMode == downloader .SnapSync {
@@ -2005,21 +2016,34 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
2005
2016
return backend .APIBackend , backend
2006
2017
}
2007
2018
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.
2010
2020
func RegisterEthStatsService (stack * node.Node , backend ethapi.Backend , url string ) {
2011
2021
if err := ethstats .New (stack , backend , backend .Engine (), url ); err != nil {
2012
2022
Fatalf ("Failed to register the Ethereum Stats service: %v" , err )
2013
2023
}
2014
2024
}
2015
2025
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 {
2019
2030
Fatalf ("Failed to register the GraphQL service: %v" , err )
2020
2031
}
2021
2032
}
2022
2033
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
+
2023
2047
func SetupMetrics (ctx * cli.Context ) {
2024
2048
if metrics .Enabled {
2025
2049
log .Info ("Enabling metrics collection" )
0 commit comments