@@ -791,6 +791,24 @@ var (
791
791
Usage : "Enables the (deprecated) personal namespace" ,
792
792
Category : flags .APICategory ,
793
793
}
794
+ // grpc
795
+ GRPCEnabledFlag = & cli.BoolFlag {
796
+ Name : "grpc" ,
797
+ Usage : "Enable the gRPC server" ,
798
+ Category : flags .APICategory ,
799
+ }
800
+ GRPCHostFlag = & cli.StringFlag {
801
+ Name : "grpc.addr" ,
802
+ Usage : "gRPC server listening interface" ,
803
+ Value : node .DefaultGRPCHost ,
804
+ Category : flags .APICategory ,
805
+ }
806
+ GRPCPortFlag = & cli.IntFlag {
807
+ Name : "grpc.port" ,
808
+ Usage : "gRPC server listening port" ,
809
+ Value : node .DefaultGRPCPort ,
810
+ Category : flags .APICategory ,
811
+ }
794
812
795
813
// Network Settings
796
814
MaxPeersFlag = & cli.IntFlag {
@@ -1211,6 +1229,19 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
1211
1229
}
1212
1230
}
1213
1231
1232
+ // setGRCP creates the gRPC RPC listener interface string from the set command
1233
+ // line flags, returning empty if the gRPC endpoint is disabled.
1234
+ func setGRCP (ctx * cli.Context , cfg * node.Config ) {
1235
+ if ctx .Bool (GRPCEnabledFlag .Name ) && cfg .GRPCHost == "" {
1236
+ if ctx .IsSet (GRPCHostFlag .Name ) {
1237
+ cfg .GRPCHost = ctx .String (GRPCHostFlag .Name )
1238
+ }
1239
+ if ctx .IsSet (GRPCPortFlag .Name ) {
1240
+ cfg .GRPCPort = ctx .Int (GRPCPortFlag .Name )
1241
+ }
1242
+ }
1243
+ }
1244
+
1214
1245
// setGraphQL creates the GraphQL listener interface string from the set
1215
1246
// command line flags, returning empty if the GraphQL endpoint is disabled.
1216
1247
func setGraphQL (ctx * cli.Context , cfg * node.Config ) {
@@ -1460,6 +1491,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
1460
1491
SetP2PConfig (ctx , & cfg .P2P )
1461
1492
setIPC (ctx , cfg )
1462
1493
setHTTP (ctx , cfg )
1494
+ setGRCP (ctx , cfg )
1463
1495
setGraphQL (ctx , cfg )
1464
1496
setWS (ctx , cfg )
1465
1497
setNodeUserIdent (ctx , cfg )
@@ -2032,6 +2064,14 @@ func RegisterGraphQLService(stack *node.Node, backend ethapi.Backend, filterSyst
2032
2064
}
2033
2065
}
2034
2066
2067
+ // RegisterGRPCService adds the gRPC API to the node.
2068
+ // It was done this way so that our grpc execution server can access the ethapi.Backend
2069
+ func RegisterGRPCService (stack * node.Node , backend ethapi.Backend , cfg * node.Config ) {
2070
+ if err := node .NewGRPCServerHandler (stack , backend , cfg ); err != nil {
2071
+ Fatalf ("Failed to register the gRPC service: %v" , err )
2072
+ }
2073
+ }
2074
+
2035
2075
// RegisterFilterAPI adds the eth log filtering RPC API to the node.
2036
2076
func RegisterFilterAPI (stack * node.Node , backend ethapi.Backend , ethcfg * ethconfig.Config ) * filters.FilterSystem {
2037
2077
isLightClient := ethcfg .SyncMode == downloader .LightSync
0 commit comments