Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
003d2ff2a7
commit
c769b1312b
@ -38,7 +38,7 @@ require (
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/core/testing v0.0.0-20240726110027-5c90246b3f9f // indirect
|
||||
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
github.com/DataDog/zstd v1.5.5 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
|
||||
12
server/v2/api/grpc/flags.go
Normal file
12
server/v2/api/grpc/flags.go
Normal file
@ -0,0 +1,12 @@
|
||||
package grpc
|
||||
|
||||
import "fmt"
|
||||
|
||||
// start flags are prefixed with the server name
|
||||
// as the config in prefixed with the server name
|
||||
// this allows viper to properly bind the flags
|
||||
func prefix(f string) string {
|
||||
return fmt.Sprintf("%s.%s", ServerName, f)
|
||||
}
|
||||
|
||||
var FlagAddress = prefix("address")
|
||||
@ -24,8 +24,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ServerName = "grpc"
|
||||
|
||||
BlockHeightHeader = "x-cosmos-block-height"
|
||||
FlagAddress = "address"
|
||||
)
|
||||
|
||||
type Server[T transaction.Tx] struct {
|
||||
@ -74,16 +75,8 @@ func (s *Server[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logge
|
||||
}
|
||||
|
||||
func (s *Server[T]) StartCmdFlags() *pflag.FlagSet {
|
||||
flags := pflag.NewFlagSet("grpc", pflag.ExitOnError)
|
||||
|
||||
// start flags are prefixed with the server name
|
||||
// as the config in prefixed with the server name
|
||||
// this allows viper to properly bind the flags
|
||||
prefix := func(f string) string {
|
||||
return fmt.Sprintf("%s.%s", s.Name(), f)
|
||||
}
|
||||
|
||||
flags.String(prefix(FlagAddress), "localhost:9090", "Listen address")
|
||||
flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError)
|
||||
flags.String(FlagAddress, "localhost:9090", "Listen address")
|
||||
return flags
|
||||
}
|
||||
|
||||
@ -151,7 +144,7 @@ func getHeightFromCtx(ctx context.Context) (uint64, error) {
|
||||
}
|
||||
|
||||
func (s *Server[T]) Name() string {
|
||||
return "grpc"
|
||||
return ServerName
|
||||
}
|
||||
|
||||
func (s *Server[T]) Config() any {
|
||||
|
||||
@ -21,6 +21,8 @@ import (
|
||||
var _ serverv2.ServerComponent[transaction.Tx] = (*GRPCGatewayServer[transaction.Tx])(nil)
|
||||
|
||||
const (
|
||||
ServerName = "grpc-gateway"
|
||||
|
||||
// GRPCBlockHeightHeader is the gRPC header for block height.
|
||||
GRPCBlockHeightHeader = "x-cosmos-block-height"
|
||||
)
|
||||
@ -64,7 +66,7 @@ func New[T transaction.Tx](grpcSrv *grpc.Server, ir jsonpb.AnyResolver, cfgOptio
|
||||
}
|
||||
|
||||
func (g *GRPCGatewayServer[T]) Name() string {
|
||||
return "grpc-gateway"
|
||||
return ServerName
|
||||
}
|
||||
|
||||
func (s *GRPCGatewayServer[T]) Config() any {
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package cometbft
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Query flags
|
||||
const (
|
||||
@ -38,12 +42,19 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) {
|
||||
_ = cmd.MarkFlagRequired(FlagChainID)
|
||||
}
|
||||
|
||||
// start flags are prefixed with the server name
|
||||
// as the config in prefixed with the server name
|
||||
// this allows viper to properly bind the flags
|
||||
func prefix(f string) string {
|
||||
return fmt.Sprintf("%s.%s", ServerName, f)
|
||||
}
|
||||
|
||||
// Server flags
|
||||
const (
|
||||
Standalone = "standalone"
|
||||
FlagAddress = "address"
|
||||
FlagTransport = "transport"
|
||||
FlagHaltHeight = "halt-height"
|
||||
FlagHaltTime = "halt-time"
|
||||
FlagTrace = "trace"
|
||||
var (
|
||||
Standalone = prefix("standalone")
|
||||
FlagAddress = prefix("address")
|
||||
FlagTransport = prefix("transport")
|
||||
FlagHaltHeight = prefix("halt-height")
|
||||
FlagHaltTime = prefix("halt-time")
|
||||
FlagTrace = prefix("trace")
|
||||
)
|
||||
|
||||
@ -28,6 +28,8 @@ import (
|
||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
const ServerName = "comet"
|
||||
|
||||
var (
|
||||
_ serverv2.ServerComponent[transaction.Tx] = (*CometBFTServer[transaction.Tx])(nil)
|
||||
_ serverv2.HasCLICommands = (*CometBFTServer[transaction.Tx])(nil)
|
||||
@ -107,7 +109,7 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger l
|
||||
}
|
||||
|
||||
func (s *CometBFTServer[T]) Name() string {
|
||||
return "comet"
|
||||
return ServerName
|
||||
}
|
||||
|
||||
func (s *CometBFTServer[T]) Start(ctx context.Context) error {
|
||||
@ -193,21 +195,21 @@ func getGenDocProvider(cfg *cmtcfg.Config) func() (node.ChecksummedGenesisDoc, e
|
||||
}
|
||||
|
||||
func (s *CometBFTServer[T]) StartCmdFlags() *pflag.FlagSet {
|
||||
flags := pflag.NewFlagSet("cometbft", pflag.ExitOnError)
|
||||
flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError)
|
||||
|
||||
// start flags are prefixed with the server name
|
||||
// as the config in prefixed with the server name
|
||||
// this allows viper to properly bind the flags
|
||||
prefix := func(f string) string {
|
||||
return fmt.Sprintf("%s.%s", s.Name(), f)
|
||||
}
|
||||
flags.String(FlagAddress, "tcp://127.0.0.1:26658", "Listen address")
|
||||
flags.String(FlagTransport, "socket", "Transport protocol: socket, grpc")
|
||||
flags.Uint64(FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
|
||||
flags.Uint64(FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
|
||||
flags.Bool(FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
|
||||
flags.Bool(Standalone, false, "Run app without CometBFT")
|
||||
|
||||
// add comet flags, we use an empty command to avoid duplicating CometBFT's AddNodeFlags.
|
||||
// we can then merge the flag sets.
|
||||
emptyCmd := &cobra.Command{}
|
||||
cmtcmd.AddNodeFlags(emptyCmd)
|
||||
flags.AddFlagSet(emptyCmd.Flags())
|
||||
|
||||
flags.String(prefix(FlagAddress), "tcp://127.0.0.1:26658", "Listen address")
|
||||
flags.String(prefix(FlagTransport), "socket", "Transport protocol: socket, grpc")
|
||||
flags.Uint64(prefix(FlagHaltHeight), 0, "Block height at which to gracefully halt the chain and shutdown the node")
|
||||
flags.Uint64(prefix(FlagHaltTime), 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
|
||||
flags.Bool(prefix(FlagTrace), false, "Provide full stack traces for errors in ABCI Log")
|
||||
flags.Bool(prefix(Standalone), false, "Run app without CometBFT")
|
||||
return flags
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user