chore: fix deprecation warnings

This commit is contained in:
Steven Allen 2019-09-26 15:38:12 -07:00
parent 9ee4adfc7c
commit 853ed0be5d
7 changed files with 12 additions and 10 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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

View File

@ -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)
}

View File

@ -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),

View File

@ -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)

View File

@ -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