normalise import aliases.

This commit is contained in:
Raúl Kripalani 2018-09-07 18:46:23 +01:00
parent 08de02b668
commit 1c25f160a1
12 changed files with 40 additions and 34 deletions

View File

@ -2,13 +2,12 @@ package peerstore
import (
"context"
"errors"
"math"
"time"
"github.com/pkg/errors"
ic "github.com/libp2p/go-libp2p-crypto"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"sync"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
)
var _ Peerstore = (*peerstore)(nil)

View File

@ -5,16 +5,16 @@ import (
"sync"
"time"
"github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru"
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
query "github.com/ipfs/go-datastore/query"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
mh "github.com/multiformats/go-multihash"
pstore "github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
)
var log = logging.Logger("peerstore/ds")

View File

@ -7,14 +7,14 @@ import (
"testing"
"time"
"github.com/ipfs/go-datastore"
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-ds-badger"
"github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-libp2p-peerstore/test"
pstore "github.com/libp2p/go-libp2p-peerstore"
pt "github.com/libp2p/go-libp2p-peerstore/test"
)
func setupBadgerDatastore(t testing.TB) (datastore.Batching, func()) {
func setupBadgerDatastore(t testing.TB) (ds.Batching, func()) {
dataPath, err := ioutil.TempDir(os.TempDir(), "badger")
if err != nil {
t.Fatal(err)
@ -30,8 +30,8 @@ func setupBadgerDatastore(t testing.TB) (datastore.Batching, func()) {
return ds, closer
}
func newPeerstoreFactory(tb testing.TB) test.PeerstoreFactory {
return func() (peerstore.Peerstore, func()) {
func newPeerstoreFactory(tb testing.TB) pt.PeerstoreFactory {
return func() (pstore.Peerstore, func()) {
ds, closeFunc := setupBadgerDatastore(tb)
ps, err := NewPeerstore(context.Background(), ds)
@ -44,11 +44,11 @@ func newPeerstoreFactory(tb testing.TB) test.PeerstoreFactory {
}
func TestBadgerDsPeerstore(t *testing.T) {
test.TestPeerstore(t, newPeerstoreFactory(t))
pt.TestPeerstore(t, newPeerstoreFactory(t))
}
func TestBadgerDsAddrBook(t *testing.T) {
test.TestAddrBook(t, func() (peerstore.AddrBook, func()) {
pt.TestAddrBook(t, func() (pstore.AddrBook, func()) {
ds, closeDB := setupBadgerDatastore(t)
mgr, err := NewAddrBook(context.Background(), ds, 100*time.Microsecond)
@ -65,5 +65,5 @@ func TestBadgerDsAddrBook(t *testing.T) {
}
func BenchmarkBadgerDsPeerstore(b *testing.B) {
test.BenchmarkPeerstore(b, newPeerstoreFactory(b))
pt.BenchmarkPeerstore(b, newPeerstoreFactory(b))
}

View File

@ -4,14 +4,14 @@ import (
"context"
"time"
"github.com/ipfs/go-datastore"
ds "github.com/ipfs/go-datastore"
pstore "github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
)
// NewPeerstore creates a peerstore backed by the provided persistent datastore.
func NewPeerstore(ctx context.Context, ds datastore.Batching) (pstore.Peerstore, error) {
func NewPeerstore(ctx context.Context, ds ds.Batching) (pstore.Peerstore, error) {
addrBook, err := NewAddrBook(ctx, ds, time.Second)
if err != nil {
return nil, err

View File

@ -7,11 +7,11 @@ import (
"time"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
pstore "github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-libp2p-peerstore/addr"
addr "github.com/libp2p/go-libp2p-peerstore/addr"
)
var log = logging.Logger("peerstore")

View File

@ -4,29 +4,29 @@ import (
"testing"
pstore "github.com/libp2p/go-libp2p-peerstore"
"github.com/libp2p/go-libp2p-peerstore/test"
pt "github.com/libp2p/go-libp2p-peerstore/test"
)
func TestInMemoryPeerstore(t *testing.T) {
test.TestPeerstore(t, func() (pstore.Peerstore, func()) {
pt.TestPeerstore(t, func() (pstore.Peerstore, func()) {
return NewPeerstore(), nil
})
}
func TestInMemoryAddrBook(t *testing.T) {
test.TestAddrBook(t, func() (pstore.AddrBook, func()) {
pt.TestAddrBook(t, func() (pstore.AddrBook, func()) {
return NewAddrBook(), nil
})
}
func TestInMemoryKeyBook(t *testing.T) {
test.TestKeyBook(t, func() (pstore.KeyBook, func()) {
pt.TestKeyBook(t, func() (pstore.KeyBook, func()) {
return NewKeyBook(), nil
})
}
func BenchmarkInMemoryPeerstore(b *testing.B) {
test.BenchmarkPeerstore(b, func() (pstore.Peerstore, func()) {
pt.BenchmarkPeerstore(b, func() (pstore.Peerstore, func()) {
return NewPeerstore(), nil
})
}

View File

@ -5,7 +5,7 @@ import (
"sync"
ic "github.com/libp2p/go-libp2p-crypto"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
)

View File

@ -3,8 +3,7 @@ package pstoremem
import (
"sync"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
)

View File

@ -4,7 +4,7 @@ import (
"sort"
"testing"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
pt "github.com/libp2p/go-libp2p-peer/test"
pstore "github.com/libp2p/go-libp2p-peerstore"

View File

@ -8,8 +8,8 @@ import (
"testing"
"time"
"github.com/libp2p/go-libp2p-crypto"
"github.com/libp2p/go-libp2p-peer"
crypto "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
ma "github.com/multiformats/go-multiaddr"
pstore "github.com/libp2p/go-libp2p-peerstore"

View File

@ -5,7 +5,7 @@ import (
"fmt"
"testing"
"github.com/libp2p/go-libp2p-peer"
peer "github.com/libp2p/go-libp2p-peer"
pt "github.com/libp2p/go-libp2p-peer/test"
ma "github.com/multiformats/go-multiaddr"
)
@ -42,3 +42,11 @@ func addressProducer(ctx context.Context, b *testing.B, addrs chan *peerpair) {
}
}
}
func multiaddr(m string) ma.Multiaddr {
maddr, err := ma.NewMultiaddr(m)
if err != nil {
panic(err)
}
return maddr
}