Merge pull request #9 from libp2p/feat/stdlib-ctx

use context from stdlib
This commit is contained in:
Jeromy Johnson 2016-10-04 18:10:56 -07:00 committed by GitHub
commit cf69e7912b
11 changed files with 38 additions and 37 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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