diff --git a/cmd/flags_node.go b/cmd/flags_node.go index 6cc3919b4e..1dcdc46a27 100644 --- a/cmd/flags_node.go +++ b/cmd/flags_node.go @@ -44,7 +44,7 @@ func ParseNodeFlags(ctx context.Context, cmd *cobra.Command, network p2p.Network if store == "" { tp := NodeType(ctx) var err error - store, err = DefaultNodeStorePath(tp.String(), string(network)) + store, err = DefaultNodeStorePath(tp.String(), network.String()) if err != nil { return ctx, err } diff --git a/nodebuilder/fraud/constructors.go b/nodebuilder/fraud/constructors.go index 8399b1b477..fc22e6afad 100644 --- a/nodebuilder/fraud/constructors.go +++ b/nodebuilder/fraud/constructors.go @@ -28,7 +28,7 @@ func newFraudService(syncerEnabled bool) func( ds datastore.Batching, network p2p.Network, ) (Module, fraud.Service, error) { - pservice := fraud.NewProofService(sub, host, hstore.GetByHeight, ds, syncerEnabled, string(network)) + pservice := fraud.NewProofService(sub, host, hstore.GetByHeight, ds, syncerEnabled, network.String()) lc.Append(fx.Hook{ OnStart: pservice.Start, OnStop: pservice.Stop, diff --git a/nodebuilder/header/module.go b/nodebuilder/header/module.go index 743f601f4d..41180a0f5f 100644 --- a/nodebuilder/header/module.go +++ b/nodebuilder/header/module.go @@ -45,7 +45,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option { p2p.WithReadDeadline(cfg.Server.ReadDeadline), p2p.WithMaxRequestSize[p2p.ServerParameters](cfg.Server.MaxRequestSize), p2p.WithRequestTimeout[p2p.ServerParameters](cfg.Server.RequestTimeout), - p2p.WithProtocolSuffix[p2p.ServerParameters](string(network)), + p2p.WithProtocolSuffix[p2p.ServerParameters](network.String()), } }), fx.Provide(newHeaderService), @@ -87,7 +87,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option { )), fx.Provide(fx.Annotate( func(ps *pubsub.PubSub, network modp2p.Network) *p2p.Subscriber[*header.ExtendedHeader] { - return p2p.NewSubscriber[*header.ExtendedHeader](ps, header.MsgID, string(network)) + return p2p.NewSubscriber[*header.ExtendedHeader](ps, header.MsgID, network.String()) }, fx.OnStart(func(ctx context.Context, sub *p2p.Subscriber[*header.ExtendedHeader]) error { return sub.Start(ctx) @@ -122,7 +122,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option { p2p.WithDefaultScore(cfg.Client.DefaultScore), p2p.WithRequestTimeout[p2p.ClientParameters](cfg.Client.RequestTimeout), p2p.WithMaxTrackerSize(cfg.Client.MaxPeerTrackerSize), - p2p.WithProtocolSuffix[p2p.ClientParameters](string(network)), + p2p.WithProtocolSuffix[p2p.ClientParameters](network.String()), } }, ), diff --git a/nodebuilder/p2p/network.go b/nodebuilder/p2p/network.go index b13c5d7311..fc37451ec9 100644 --- a/nodebuilder/p2p/network.go +++ b/nodebuilder/p2p/network.go @@ -43,6 +43,11 @@ func (n Network) Validate() (Network, error) { return n, nil } +// String returns string representation of the Network. +func (n Network) String() string { + return string(n) +} + // networksList is a strict list of all known long-standing networks. var networksList = map[Network]struct{}{ Arabica: {}, diff --git a/nodebuilder/share/module.go b/nodebuilder/share/module.go index 64aeabcdfa..1f963b9987 100644 --- a/nodebuilder/share/module.go +++ b/nodebuilder/share/module.go @@ -67,7 +67,7 @@ func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option fx.Invoke(func(edsSrv *shrexeds.Server, ndSrc *shrexnd.Server) {}), fx.Provide(fx.Annotate( func(host host.Host, store *eds.Store, network modp2p.Network) (*shrexeds.Server, error) { - return shrexeds.NewServer(host, store, shrexeds.WithProtocolSuffix(string(network))) + return shrexeds.NewServer(host, store, shrexeds.WithProtocolSuffix(network.String())) }, fx.OnStart(func(ctx context.Context, server *shrexeds.Server) error { return server.Start(ctx) @@ -83,7 +83,7 @@ func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option getter *getters.IPLDGetter, network modp2p.Network, ) (*shrexnd.Server, error) { - return shrexnd.NewServer(host, store, getter, shrexnd.WithProtocolSuffix(string(network))) + return shrexnd.NewServer(host, store, getter, shrexnd.WithProtocolSuffix(network.String())) }, fx.OnStart(func(ctx context.Context, server *shrexnd.Server) error { return server.Start(ctx) @@ -126,12 +126,12 @@ func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option fx.Provide(fullGetter), fx.Provide( func(host host.Host, network modp2p.Network) (*shrexnd.Client, error) { - return shrexnd.NewClient(host, shrexnd.WithProtocolSuffix(string(network))) + return shrexnd.NewClient(host, shrexnd.WithProtocolSuffix(network.String())) }, ), fx.Provide( func(host host.Host, network modp2p.Network) (*shrexeds.Client, error) { - return shrexeds.NewClient(host, shrexeds.WithProtocolSuffix(string(network))) + return shrexeds.NewClient(host, shrexeds.WithProtocolSuffix(network.String())) }, ), fx.Provide(fx.Annotate( @@ -148,7 +148,7 @@ func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option return shrexsub.NewPubSub( ctx, h, - string(network), + network.String(), ) }, ),