提交 853ed0be 作者: Steven Allen

chore: fix deprecation warnings

上级 9ee4adfc
......@@ -8,6 +8,7 @@ import (
"io"
"strings"
version "github.com/ipfs/go-ipfs"
core "github.com/ipfs/go-ipfs/core"
cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv"
......@@ -189,6 +190,6 @@ func printSelf(node *core.IpfsNode) (interface{}, error) {
}
}
info.ProtocolVersion = identify.LibP2PVersion
info.AgentVersion = identify.ClientVersion
info.AgentVersion = version.UserAgent
return info, nil
}
......@@ -12,10 +12,8 @@ package core
import (
"context"
"io"
"path"
"github.com/ipfs/go-filestore"
version "github.com/ipfs/go-ipfs"
"github.com/ipfs/go-ipfs/core/bootstrap"
"github.com/ipfs/go-ipfs/core/node"
"github.com/ipfs/go-ipfs/core/node/libp2p"
......@@ -49,15 +47,10 @@ import (
record "github.com/libp2p/go-libp2p-record"
"github.com/libp2p/go-libp2p/p2p/discovery"
p2pbhost "github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
)
var log = logging.Logger("core")
func init() {
identify.ClientVersion = path.Join("go-ipfs", version.CurrentVersionNumber, version.CurrentCommit)
}
// IpfsNode is IPFS Core module. It represents an IPFS instance.
type IpfsNode struct {
......
......@@ -104,7 +104,7 @@ func VersionOption() ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit)
fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion)
fmt.Fprintf(w, "Client Version: %s\n", version.UserAgent)
fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion)
})
return mux, nil
......
......@@ -608,7 +608,7 @@ func TestVersion(t *testing.T) {
t.Fatalf("response doesn't contain commit:\n%s", s)
}
if !strings.Contains(s, "Client Version: "+id.ClientVersion) {
if !strings.Contains(s, "Client Version: "+version.UserAgent) {
t.Fatalf("response doesn't contain client version:\n%s", s)
}
......
......@@ -23,6 +23,7 @@ import (
)
var BaseLibP2P = fx.Options(
fx.Provide(libp2p.UserAgent),
fx.Provide(libp2p.PNet),
fx.Provide(libp2p.ConnectionManager),
fx.Provide(libp2p.DefaultTransports),
......
......@@ -3,6 +3,8 @@ package libp2p
import (
"time"
version "github.com/ipfs/go-ipfs"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-connmgr"
......@@ -22,6 +24,8 @@ type Libp2pOpts struct {
// Misc options
var UserAgent = simpleOpt(libp2p.UserAgent(version.UserAgent))
func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
cm := connmgr.NewConnManager(low, high, grace)
......
......@@ -7,3 +7,6 @@ var CurrentCommit string
const CurrentVersionNumber = "0.5.0-dev"
const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"
// UserAgent is the libp2p user agent used by go-ipfs.
var UserAgent = ApiVersion + CurrentCommit
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论