make libp2p user agent overridable

This commit is contained in:
Richard Guan
2023-01-31 21:40:55 +09:00
parent 34576d0c64
commit a8dace0f23
2 changed files with 9 additions and 1 deletions
+7
View File
@@ -114,3 +114,10 @@ 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
}
}