nitro server clean up

go mod update
This commit is contained in:
Roy Crihfield 2024-12-28 22:03:36 +08:00
parent f0f96bc28e
commit 054a7f2c6a
3 changed files with 14 additions and 15 deletions

2
go.mod
View File

@ -45,7 +45,6 @@ require (
github.com/rs/cors v1.11.1
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/statechannels/go-nitro v0.2.0
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.14.4
@ -73,6 +72,7 @@ require (
)
require (
github.com/spf13/viper v1.19.0 // indirect
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.2-20241120201313-68e42a58b301.1 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.2-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/core/testing v0.0.0 // indirect

View File

@ -7,8 +7,6 @@ import (
)
// 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)
}

View File

@ -8,6 +8,7 @@ import (
"strings"
"cosmossdk.io/core/server"
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
serverv2 "cosmossdk.io/server/v2"
"github.com/cosmos/cosmos-sdk/client"
@ -33,9 +34,10 @@ const (
)
var (
_ serverv2.HasStartFlags = (*Server)(nil)
_ serverv2.HasCLICommands = (*Server)(nil)
_ serverv2.HasConfig = (*Server)(nil)
_ serverv2.ServerComponent[transaction.Tx] = (*Server)(nil)
_ serverv2.HasCLICommands = (*Server)(nil)
_ serverv2.HasStartFlags = (*Server)(nil)
_ serverv2.HasConfig = (*Server)(nil)
// _ serverv2.ConfigWriter = (*Server)(nil)
)
@ -59,13 +61,12 @@ func New(logger log.Logger, cfg server.ConfigMap) (*Server, error) {
logger: logger.With(log.ModuleKey, serverName),
storeDir: filepath.Join(home, "nitro")}
c := s.Config().(*Config)
s.config = s.Config().(*Config)
if len(cfg) > 0 {
if err := serverv2.UnmarshalSubConfig(cfg, s.Name(), &c); err != nil {
if err := serverv2.UnmarshalSubConfig(cfg, s.Name(), &s.config); err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
}
s.config = c
return s, nil
}
@ -187,12 +188,6 @@ func (s *Server) Stop(context.Context) error {
return nil
}
func (s *Server) StartCmdFlags() *pflag.FlagSet {
flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError)
AddNitroFlags(flags)
return flags
}
func (s *Server) Config() any {
if s.config == nil {
return DefaultConfig()
@ -200,6 +195,12 @@ func (s *Server) Config() any {
return s.config
}
func (s *Server) StartCmdFlags() *pflag.FlagSet {
flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError)
AddNitroFlags(flags)
return flags
}
// func (s *Server) WriteConfig(path string) error
func (s *Server) CLICommands() serverv2.CLIConfig {