mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
Add --rpc-host option to beacon chain (#4571)
This commit is contained in:
parent
eb429ab719
commit
dab87ba252
@ -27,6 +27,12 @@ var (
|
||||
Name: "deposit-contract",
|
||||
Usage: "Deposit contract address. Beacon chain node will listen logs coming from the deposit contract to determine when validator is eligible to participate.",
|
||||
}
|
||||
// RPCHost defines the host on which the RPC server should listen.
|
||||
RPCHost = cli.StringFlag{
|
||||
Name: "rpc-host",
|
||||
Usage: "Host on which the RPC server should listen",
|
||||
Value: "0.0.0.0",
|
||||
}
|
||||
// RPCPort defines a beacon node RPC port to open.
|
||||
RPCPort = cli.IntFlag{
|
||||
Name: "rpc-port",
|
||||
|
@ -28,6 +28,7 @@ var appFlags = []cli.Flag{
|
||||
flags.DepositContractFlag,
|
||||
flags.Web3ProviderFlag,
|
||||
flags.HTTPWeb3ProviderFlag,
|
||||
flags.RPCHost,
|
||||
flags.RPCPort,
|
||||
flags.CertFlag,
|
||||
flags.KeyFlag,
|
||||
|
@ -446,6 +446,7 @@ func (b *BeaconNode) registerRPCService(ctx *cli.Context) error {
|
||||
chainStartFetcher = web3Service
|
||||
}
|
||||
|
||||
host := ctx.GlobalString(flags.RPCHost.Name)
|
||||
port := ctx.GlobalString(flags.RPCPort.Name)
|
||||
cert := ctx.GlobalString(flags.CertFlag.Name)
|
||||
key := ctx.GlobalString(flags.KeyFlag.Name)
|
||||
@ -454,6 +455,7 @@ func (b *BeaconNode) registerRPCService(ctx *cli.Context) error {
|
||||
|
||||
mockEth1DataVotes := ctx.GlobalBool(flags.InteropMockEth1DataVotesFlag.Name)
|
||||
rpcService := rpc.NewService(context.Background(), &rpc.Config{
|
||||
Host: host,
|
||||
Port: port,
|
||||
CertFlag: cert,
|
||||
KeyFlag: key,
|
||||
|
@ -65,6 +65,7 @@ type Service struct {
|
||||
mockEth1Votes bool
|
||||
attestationsPool attestations.Pool
|
||||
syncService sync.Checker
|
||||
host string
|
||||
port string
|
||||
listener net.Listener
|
||||
withCert string
|
||||
@ -88,6 +89,7 @@ type Service struct {
|
||||
|
||||
// Config options for the beacon node RPC server.
|
||||
type Config struct {
|
||||
Host string
|
||||
Port string
|
||||
CertFlag string
|
||||
KeyFlag string
|
||||
@ -136,6 +138,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
mockEth1Votes: cfg.MockEth1Votes,
|
||||
attestationsPool: cfg.AttestationsPool,
|
||||
syncService: cfg.SyncService,
|
||||
host: cfg.Host,
|
||||
port: cfg.Port,
|
||||
withCert: cfg.CertFlag,
|
||||
withKey: cfg.KeyFlag,
|
||||
@ -152,12 +155,13 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
|
||||
// Start the gRPC server.
|
||||
func (s *Service) Start() {
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%s", s.port))
|
||||
address := fmt.Sprintf("%s:%s", s.host, s.port)
|
||||
lis, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Errorf("Could not listen to port in Start() :%s: %v", s.port, err)
|
||||
log.Errorf("Could not listen to port in Start() %s: %v", address, err)
|
||||
}
|
||||
s.listener = lis
|
||||
log.WithField("port", fmt.Sprintf(":%s", s.port)).Info("RPC-API listening on port")
|
||||
log.WithField("address", address).Info("RPC-API listening on port")
|
||||
|
||||
opts := []grpc.ServerOption{
|
||||
grpc.StatsHandler(&ocgrpc.ServerHandler{}),
|
||||
|
@ -82,6 +82,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
flags.DepositContractFlag,
|
||||
flags.ContractDeploymentBlock,
|
||||
flags.Web3ProviderFlag,
|
||||
flags.RPCHost,
|
||||
flags.RPCPort,
|
||||
flags.RPCMaxPageSize,
|
||||
flags.CertFlag,
|
||||
|
Loading…
Reference in New Issue
Block a user