Skip to content

Commit 4f2fe56

Browse files
authored
fix: set user agent from boost build version instead of lotus (#1305)
1 parent f3622c8 commit 4f2fe56

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

node/builder.go

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ var (
105105
ConnGaterKey = special{12} // libp2p option
106106
DAGStoreKey = special{13} // constructor returns multiple values
107107
ResourceManagerKey = special{14} // Libp2p option
108+
UserAgentKey = special{15} // Libp2p option
108109
)
109110

110111
type invoke int
@@ -227,6 +228,8 @@ var LibP2P = Options(
227228
Override(SmuxTransportKey, lotus_lp2p.SmuxTransport()),
228229
Override(RelayKey, lotus_lp2p.NoRelay()),
229230
Override(SecurityKey, lotus_lp2p.Security(true, false)),
231+
Override(DefaultTransportsKey, lp2p.DefaultTransports),
232+
Override(UserAgentKey, modules.UserAgent),
230233

231234
// Host
232235
Override(new(lotus_lp2p.RawHost), lotus_lp2p.Host),

node/modules/lp2p.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package modules
2+
3+
import (
4+
"github.com/filecoin-project/boost/build"
5+
"github.com/filecoin-project/lotus/node/modules/lp2p"
6+
"github.com/libp2p/go-libp2p"
7+
)
8+
9+
func simpleOpt(opt libp2p.Option) func() (opts lp2p.Libp2pOpts, err error) {
10+
return func() (opts lp2p.Libp2pOpts, err error) {
11+
opts.Opts = append(opts.Opts, opt)
12+
return
13+
}
14+
}
15+
16+
var UserAgent = simpleOpt(libp2p.UserAgent("boost-" + build.UserVersion()))

0 commit comments

Comments
 (0)