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: os:
- linux - linux
- osx - osx
language: go language: go
@ -9,12 +9,16 @@ go:
install: true install: true
before_install:
- make deps
script: script:
- make deps - go vet
- gx-go rewrite - $GOPATH/bin/goveralls -service="travis-ci"
- go get github.com/mattn/goveralls
- goveralls -service=travis-ci
cache: cache:
directories: directories:
- $GOPATH/src/gx - $GOPATH/src/gx
notifications:
email: false

View File

@ -1,14 +1,17 @@
test: deps
go test -race -v ./...
export IPFS_API ?= v04x.ipfs.io export IPFS_API ?= v04x.ipfs.io
gx: gx:
go get -u github.com/whyrusleeping/gx go get github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go 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 --verbose install --global
gx-go rewrite gx-go rewrite
go get -t ./...
publish:
gx-go rewrite --undo

View File

@ -1,9 +1,9 @@
# go-libp2p-peer # 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/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) [![](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) [![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/ipfs/go-libp2p-peerstore/badge.svg?branch=master)](https://coveralls.io/github/ipfs/go-libp2p-peerstore?branch=master) [![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/ipfs/go-libp2p-peerstore.svg?branch=master)](https://travis-ci.org/ipfs/go-libp2p-peerstore) [![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. An object to manage peers, their addresses, and other metadata about them.

View File

@ -1,14 +1,14 @@
package peerstore package peerstore
import ( import (
"context"
"sort" "sort"
"sync" "sync"
"time" "time"
peer "github.com/ipfs/go-libp2p-peer" peer "github.com/ipfs/go-libp2p-peer"
addr "github.com/ipfs/go-libp2p-peerstore/addr"
ma "github.com/jbenet/go-multiaddr" ma "github.com/jbenet/go-multiaddr"
"golang.org/x/net/context" addr "github.com/libp2p/go-libp2p-peerstore/addr"
) )
const ( const (

View File

@ -40,7 +40,7 @@ func testHas(t *testing.T, exp, act []ma.Multiaddr) {
} }
if !found { 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 latmu sync.RWMutex
} }
func NewMetrics() Metrics { func NewMetrics() *metrics {
return &metrics{ return &metrics{
latmap: make(map[peer.ID]time.Duration), latmap: make(map[peer.ID]time.Duration),
} }

View File

@ -1,10 +1,10 @@
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"bugs": { "bugs": {
"url": "https://github.com/ipfs/go-libp2p-peerstore" "url": "https://github.com/libp2p/go-libp2p-peerstore"
}, },
"gx": { "gx": {
"dvcsimport": "github.com/ipfs/go-libp2p-peerstore" "dvcsimport": "github.com/libp2p/go-libp2p-peerstore"
}, },
"gxDependencies": [ "gxDependencies": [
{ {
@ -25,12 +25,6 @@
"name": "go-multiaddr", "name": "go-multiaddr",
"version": "0.0.0" "version": "0.0.0"
}, },
{
"author": "whyrusleeping",
"hash": "QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt",
"name": "go-net",
"version": "0.0.0"
},
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmUusaX99BZoELh7dmPgirqRQ1FAmMnmnBn3oiqDFGBUSc", "hash": "QmUusaX99BZoELh7dmPgirqRQ1FAmMnmnBn3oiqDFGBUSc",

View File

@ -1,6 +1,7 @@
package peerstore package peerstore
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"sync" "sync"
@ -13,7 +14,6 @@ import (
"github.com/ipfs/go-libp2p-peer" "github.com/ipfs/go-libp2p-peer"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr" ma "github.com/jbenet/go-multiaddr"
"golang.org/x/net/context"
) )
var log = logging.Logger("peerstore") var log = logging.Logger("peerstore")
@ -163,8 +163,8 @@ func (kb *keybook) AddPrivKey(p peer.ID, sk ic.PrivKey) error {
} }
type peerstore struct { type peerstore struct {
keybook *keybook
metrics *metrics
AddrManager AddrManager
// store other data, like versions // store other data, like versions
@ -180,8 +180,8 @@ type peerstore struct {
// NewPeerstore creates a threadsafe collection of peers. // NewPeerstore creates a threadsafe collection of peers.
func NewPeerstore() Peerstore { func NewPeerstore() Peerstore {
return &peerstore{ return &peerstore{
keybook: *newKeybook(), keybook: newKeybook(),
metrics: *(NewMetrics()).(*metrics), metrics: NewMetrics(),
AddrManager: AddrManager{}, AddrManager: AddrManager{},
//ds: dssync.MutexWrap(ds.NewMapDatastore()), //ds: dssync.MutexWrap(ds.NewMapDatastore()),
ds: make(map[string]interface{}), ds: make(map[string]interface{}),

View File

@ -1,6 +1,7 @@
package peerstore package peerstore
import ( import (
"context"
"fmt" "fmt"
"math/rand" "math/rand"
"sort" "sort"
@ -9,7 +10,6 @@ import (
peer "github.com/ipfs/go-libp2p-peer" peer "github.com/ipfs/go-libp2p-peer"
ma "github.com/jbenet/go-multiaddr" ma "github.com/jbenet/go-multiaddr"
"golang.org/x/net/context"
) )
func getAddrs(t *testing.T, n int) []ma.Multiaddr { func getAddrs(t *testing.T, n int) []ma.Multiaddr {

View File

@ -1,6 +1,7 @@
package queue package queue
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
"testing" "testing"
@ -8,8 +9,6 @@ import (
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
peer "github.com/ipfs/go-libp2p-peer" peer "github.com/ipfs/go-libp2p-peer"
context "golang.org/x/net/context"
) )
func TestQueue(t *testing.T) { func TestQueue(t *testing.T) {

View File

@ -1,9 +1,10 @@
package queue package queue
import ( import (
"context"
peer "github.com/ipfs/go-libp2p-peer" peer "github.com/ipfs/go-libp2p-peer"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
context "golang.org/x/net/context"
) )
var log = logging.Logger("peerqueue") var log = logging.Logger("peerqueue")