move UserAgentOption upwards

This commit is contained in:
Richard Guan 2023-01-31 21:46:24 +09:00
parent a8dace0f23
commit 45ceb5d297

View File

@ -69,6 +69,13 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (RawHost,
return h, nil
}
func UserAgentOption(agent string) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
opts.Opts = append(opts.Opts, libp2p.UserAgent(agent))
return
}
}
func MockHost(mn mocknet.Mocknet, id peer.ID, ps peerstore.Peerstore) (RawHost, error) {
return mn.AddPeerWithPeerstore(id, ps)
}
@ -114,10 +121,3 @@ func NilRouting(mctx helpers.MetricsCtx) (BaseIpfsRouting, error) {
func RoutedHost(rh RawHost, r BaseIpfsRouting) host.Host {
return routedhost.Wrap(rh, r)
}
func UserAgentOption(agent string) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
opts.Opts = append(opts.Opts, libp2p.UserAgent(agent))
return
}
}