diff --git a/.travis.yml b/.travis.yml index 3fd7103..73a4b6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ os: - - linux - - osx + - linux + - osx language: go @@ -9,12 +9,16 @@ go: install: true +before_install: + - make deps + script: - - make deps - - gx-go rewrite - - go get github.com/mattn/goveralls - - goveralls -service=travis-ci + - go vet + - $GOPATH/bin/goveralls -service="travis-ci" cache: directories: - $GOPATH/src/gx + +notifications: + email: false diff --git a/Makefile b/Makefile index 7c146b1..1865d9c 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ -test: deps - go test -race -v ./... - export IPFS_API ?= v04x.ipfs.io gx: - go get -u github.com/whyrusleeping/gx - go get -u github.com/whyrusleeping/gx-go + go get github.com/whyrusleeping/gx + go get github.com/whyrusleeping/gx-go -deps: gx +covertools: + go get github.com/mattn/goveralls + go get golang.org/x/tools/cmd/cover + +deps: gx covertools gx --verbose install --global gx-go rewrite - go get -t ./... + +publish: + gx-go rewrite --undo diff --git a/README.md b/README.md index e0c00c9..e6662fa 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # go-libp2p-peer [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![GoDoc](https://godoc.org/github.com/ipfs/go-libp2p-peer?status.svg)](https://godoc.org/github.com/ipfs/go-libp2p-peerstore) -[![Coverage Status](https://coveralls.io/repos/github/ipfs/go-libp2p-peerstore/badge.svg?branch=master)](https://coveralls.io/github/ipfs/go-libp2p-peerstore?branch=master) -[![Build Status](https://travis-ci.org/ipfs/go-libp2p-peerstore.svg?branch=master)](https://travis-ci.org/ipfs/go-libp2p-peerstore) +[![GoDoc](https://godoc.org/github.com/libp2p/go-libp2p-peer?status.svg)](https://godoc.org/github.com/libp2p/go-libp2p-peerstore) +[![Coverage Status](https://coveralls.io/repos/github/libp2p/go-libp2p-peerstore/badge.svg?branch=master)](https://coveralls.io/github/libp2p/go-libp2p-peerstore?branch=master) +[![Build Status](https://travis-ci.org/libp2p/go-libp2p-peerstore.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-peerstore) An object to manage peers, their addresses, and other metadata about them. diff --git a/addr_manager.go b/addr_manager.go index 877af2c..303e8e0 100644 --- a/addr_manager.go +++ b/addr_manager.go @@ -1,14 +1,14 @@ package peerstore import ( + "context" "sort" "sync" "time" peer "github.com/ipfs/go-libp2p-peer" - addr "github.com/ipfs/go-libp2p-peerstore/addr" ma "github.com/jbenet/go-multiaddr" - "golang.org/x/net/context" + addr "github.com/libp2p/go-libp2p-peerstore/addr" ) const ( diff --git a/addr_manager_test.go b/addr_manager_test.go index a480ee7..04a2a97 100644 --- a/addr_manager_test.go +++ b/addr_manager_test.go @@ -40,7 +40,7 @@ func testHas(t *testing.T, exp, act []ma.Multiaddr) { } if !found { - t.Fatal("expected address %s not found", a) + t.Fatalf("expected address %s not found", a) } } } diff --git a/metrics.go b/metrics.go index 2045ed9..94b0acc 100644 --- a/metrics.go +++ b/metrics.go @@ -29,7 +29,7 @@ type metrics struct { latmu sync.RWMutex } -func NewMetrics() Metrics { +func NewMetrics() *metrics { return &metrics{ latmap: make(map[peer.ID]time.Duration), } diff --git a/package.json b/package.json index aee8356..7ae0f3b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "author": "whyrusleeping", "bugs": { - "url": "https://github.com/ipfs/go-libp2p-peerstore" + "url": "https://github.com/libp2p/go-libp2p-peerstore" }, "gx": { - "dvcsimport": "github.com/ipfs/go-libp2p-peerstore" + "dvcsimport": "github.com/libp2p/go-libp2p-peerstore" }, "gxDependencies": [ { @@ -25,12 +25,6 @@ "name": "go-multiaddr", "version": "0.0.0" }, - { - "author": "whyrusleeping", - "hash": "QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt", - "name": "go-net", - "version": "0.0.0" - }, { "author": "whyrusleeping", "hash": "QmUusaX99BZoELh7dmPgirqRQ1FAmMnmnBn3oiqDFGBUSc", diff --git a/peerstore.go b/peerstore.go index 7518b45..e26c0ad 100644 --- a/peerstore.go +++ b/peerstore.go @@ -1,6 +1,7 @@ package peerstore import ( + "context" "errors" "fmt" "sync" @@ -13,7 +14,6 @@ import ( "github.com/ipfs/go-libp2p-peer" logging "github.com/ipfs/go-log" ma "github.com/jbenet/go-multiaddr" - "golang.org/x/net/context" ) var log = logging.Logger("peerstore") @@ -163,8 +163,8 @@ func (kb *keybook) AddPrivKey(p peer.ID, sk ic.PrivKey) error { } type peerstore struct { - keybook - metrics + *keybook + *metrics AddrManager // store other data, like versions @@ -180,8 +180,8 @@ type peerstore struct { // NewPeerstore creates a threadsafe collection of peers. func NewPeerstore() Peerstore { return &peerstore{ - keybook: *newKeybook(), - metrics: *(NewMetrics()).(*metrics), + keybook: newKeybook(), + metrics: NewMetrics(), AddrManager: AddrManager{}, //ds: dssync.MutexWrap(ds.NewMapDatastore()), ds: make(map[string]interface{}), diff --git a/peerstore_test.go b/peerstore_test.go index 44d7c22..a1a3096 100644 --- a/peerstore_test.go +++ b/peerstore_test.go @@ -1,6 +1,7 @@ package peerstore import ( + "context" "fmt" "math/rand" "sort" @@ -9,7 +10,6 @@ import ( peer "github.com/ipfs/go-libp2p-peer" ma "github.com/jbenet/go-multiaddr" - "golang.org/x/net/context" ) func getAddrs(t *testing.T, n int) []ma.Multiaddr { diff --git a/queue/queue_test.go b/queue/queue_test.go index 2daa5bd..94c24e3 100644 --- a/queue/queue_test.go +++ b/queue/queue_test.go @@ -1,6 +1,7 @@ package queue import ( + "context" "fmt" "sync" "testing" @@ -8,8 +9,6 @@ import ( u "github.com/ipfs/go-ipfs-util" peer "github.com/ipfs/go-libp2p-peer" - - context "golang.org/x/net/context" ) func TestQueue(t *testing.T) { diff --git a/queue/sync.go b/queue/sync.go index 0ff94f7..8ceedce 100644 --- a/queue/sync.go +++ b/queue/sync.go @@ -1,9 +1,10 @@ package queue import ( + "context" + peer "github.com/ipfs/go-libp2p-peer" logging "github.com/ipfs/go-log" - context "golang.org/x/net/context" ) var log = logging.Logger("peerqueue")