mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-26 23:30:32 +08:00
dep: switch to core (#80)
* dep: switch to core Specifically, remove go-libp2p-{crypto,peer} deps. * catch a few more usages of deprecated packages.
This commit is contained in:
parent
aeb6adb266
commit
0b5b389640
2
go.mod
2
go.mod
@ -9,8 +9,6 @@ require (
|
|||||||
github.com/ipfs/go-log v0.0.1
|
github.com/ipfs/go-log v0.0.1
|
||||||
github.com/libp2p/go-buffer-pool v0.0.1
|
github.com/libp2p/go-buffer-pool v0.0.1
|
||||||
github.com/libp2p/go-libp2p-core v0.0.1
|
github.com/libp2p/go-libp2p-core v0.0.1
|
||||||
github.com/libp2p/go-libp2p-crypto v0.1.0
|
|
||||||
github.com/libp2p/go-libp2p-peer v0.2.0
|
|
||||||
github.com/multiformats/go-base32 v0.0.3
|
github.com/multiformats/go-base32 v0.0.3
|
||||||
github.com/multiformats/go-multiaddr v0.0.2
|
github.com/multiformats/go-multiaddr v0.0.2
|
||||||
github.com/multiformats/go-multiaddr-net v0.0.1
|
github.com/multiformats/go-multiaddr-net v0.0.1
|
||||||
|
4
go.sum
4
go.sum
@ -70,10 +70,6 @@ github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg
|
|||||||
github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8=
|
github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8=
|
||||||
github.com/libp2p/go-libp2p-core v0.0.1 h1:HSTZtFIq/W5Ue43Zw+uWZyy2Vl5WtF0zDjKN8/DT/1I=
|
github.com/libp2p/go-libp2p-core v0.0.1 h1:HSTZtFIq/W5Ue43Zw+uWZyy2Vl5WtF0zDjKN8/DT/1I=
|
||||||
github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco=
|
github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco=
|
||||||
github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ=
|
|
||||||
github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI=
|
|
||||||
github.com/libp2p/go-libp2p-peer v0.2.0 h1:EQ8kMjaCUwt/Y5uLgjT8iY2qg0mGUT0N1zUjer50DsY=
|
|
||||||
github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY=
|
|
||||||
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
||||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||||
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw=
|
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw=
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
moved "github.com/libp2p/go-libp2p-core/peerstore"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
"github.com/libp2p/go-libp2p-peer"
|
core "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LatencyEWMASmooting governs the decay of the EWMA (the speed
|
// LatencyEWMASmooting governs the decay of the EWMA (the speed
|
||||||
@ -14,7 +14,7 @@ import (
|
|||||||
var LatencyEWMASmoothing = 0.1
|
var LatencyEWMASmoothing = 0.1
|
||||||
|
|
||||||
// Deprecated: use github.com/libp2p/go-libp2p-core/peerstore.Metrics instead.
|
// Deprecated: use github.com/libp2p/go-libp2p-core/peerstore.Metrics instead.
|
||||||
type Metrics = moved.Metrics
|
type Metrics = core.Metrics
|
||||||
|
|
||||||
type metrics struct {
|
type metrics struct {
|
||||||
latmap map[peer.ID]time.Duration
|
latmap map[peer.ID]time.Duration
|
||||||
|
@ -7,14 +7,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-peer/test"
|
"github.com/libp2p/go-libp2p-core/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLatencyEWMAFun(t *testing.T) {
|
func TestLatencyEWMAFun(t *testing.T) {
|
||||||
t.Skip("run it for fun")
|
t.Skip("run it for fun")
|
||||||
|
|
||||||
m := NewMetrics()
|
m := NewMetrics()
|
||||||
id, err := testutil.RandPeerID()
|
id, err := test.RandPeerID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ func TestLatencyEWMAFun(t *testing.T) {
|
|||||||
|
|
||||||
func TestLatencyEWMA(t *testing.T) {
|
func TestLatencyEWMA(t *testing.T) {
|
||||||
m := NewMetrics()
|
m := NewMetrics()
|
||||||
id, err := testutil.RandPeerID()
|
id, err := test.RandPeerID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
proto "github.com/gogo/protobuf/proto"
|
proto "github.com/gogo/protobuf/proto"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pt "github.com/libp2p/go-libp2p-peer/test"
|
pt "github.com/libp2p/go-libp2p-core/test"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
27
peerstore.go
27
peerstore.go
@ -4,23 +4,24 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ Peerstore = (*peerstore)(nil)
|
var _ pstore.Peerstore = (*peerstore)(nil)
|
||||||
|
|
||||||
type peerstore struct {
|
type peerstore struct {
|
||||||
Metrics
|
pstore.Metrics
|
||||||
|
|
||||||
KeyBook
|
pstore.KeyBook
|
||||||
AddrBook
|
pstore.AddrBook
|
||||||
ProtoBook
|
pstore.ProtoBook
|
||||||
PeerMetadata
|
pstore.PeerMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPeerstore creates a data structure that stores peer data, backed by the
|
// NewPeerstore creates a data structure that stores peer data, backed by the
|
||||||
// supplied implementations of KeyBook, AddrBook and PeerMetadata.
|
// supplied implementations of KeyBook, AddrBook and PeerMetadata.
|
||||||
func NewPeerstore(kb KeyBook, ab AddrBook, pb ProtoBook, md PeerMetadata) Peerstore {
|
func NewPeerstore(kb pstore.KeyBook, ab pstore.AddrBook, pb pstore.ProtoBook, md pstore.PeerMetadata) pstore.Peerstore {
|
||||||
return &peerstore{
|
return &peerstore{
|
||||||
KeyBook: kb,
|
KeyBook: kb,
|
||||||
AddrBook: ab,
|
AddrBook: ab,
|
||||||
@ -67,22 +68,22 @@ func (ps *peerstore) Peers() peer.IDSlice {
|
|||||||
return pps
|
return pps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *peerstore) PeerInfo(p peer.ID) PeerInfo {
|
func (ps *peerstore) PeerInfo(p peer.ID) peer.AddrInfo {
|
||||||
return PeerInfo{
|
return peer.AddrInfo{
|
||||||
ID: p,
|
ID: p,
|
||||||
Addrs: ps.AddrBook.Addrs(p),
|
Addrs: ps.AddrBook.Addrs(p),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func PeerInfos(ps Peerstore, peers peer.IDSlice) []PeerInfo {
|
func PeerInfos(ps pstore.Peerstore, peers peer.IDSlice) []peer.AddrInfo {
|
||||||
pi := make([]PeerInfo, len(peers))
|
pi := make([]peer.AddrInfo, len(peers))
|
||||||
for i, p := range peers {
|
for i, p := range peers {
|
||||||
pi[i] = ps.PeerInfo(p)
|
pi[i] = ps.PeerInfo(p)
|
||||||
}
|
}
|
||||||
return pi
|
return pi
|
||||||
}
|
}
|
||||||
|
|
||||||
func PeerInfoIDs(pis []PeerInfo) peer.IDSlice {
|
func PeerInfoIDs(pis []peer.AddrInfo) peer.IDSlice {
|
||||||
ps := make(peer.IDSlice, len(pis))
|
ps := make(peer.IDSlice, len(pis))
|
||||||
for i, pi := range pis {
|
for i, pi := range pis {
|
||||||
ps[i] = pi.ID
|
ps[i] = pi.ID
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
query "github.com/ipfs/go-datastore/query"
|
query "github.com/ipfs/go-datastore/query"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
||||||
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
|
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
query "github.com/ipfs/go-datastore/query"
|
query "github.com/ipfs/go-datastore/query"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
||||||
|
|
||||||
b32 "github.com/multiformats/go-base32"
|
b32 "github.com/multiformats/go-base32"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
query "github.com/ipfs/go-datastore/query"
|
query "github.com/ipfs/go-datastore/query"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
test "github.com/libp2p/go-libp2p-peerstore/test"
|
test "github.com/libp2p/go-libp2p-peerstore/test"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
badger "github.com/ipfs/go-ds-badger"
|
badger "github.com/ipfs/go-ds-badger"
|
||||||
leveldb "github.com/ipfs/go-ds-leveldb"
|
leveldb "github.com/ipfs/go-ds-leveldb"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
pt "github.com/libp2p/go-libp2p-peerstore/test"
|
pt "github.com/libp2p/go-libp2p-peerstore/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
query "github.com/ipfs/go-datastore/query"
|
query "github.com/ipfs/go-datastore/query"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-crypto"
|
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Public and private keys are stored under the following db key pattern:
|
// Public and private keys are stored under the following db key pattern:
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
|
|
||||||
pool "github.com/libp2p/go-buffer-pool"
|
pool "github.com/libp2p/go-buffer-pool"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Metadata is stored under the following db key pattern:
|
// Metadata is stored under the following db key pattern:
|
||||||
|
@ -9,7 +9,8 @@ import (
|
|||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
query "github.com/ipfs/go-datastore/query"
|
query "github.com/ipfs/go-datastore/query"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
peerstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ func DefaultOpts() Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewPeerstore creates a peerstore backed by the provided persistent datastore.
|
// NewPeerstore creates a peerstore backed by the provided persistent datastore.
|
||||||
func NewPeerstore(ctx context.Context, store ds.Batching, opts Options) (pstore.Peerstore, error) {
|
func NewPeerstore(ctx context.Context, store ds.Batching, opts Options) (peerstore.Peerstore, error) {
|
||||||
addrBook, err := NewAddrBook(ctx, store, opts)
|
addrBook, err := NewAddrBook(ctx, store, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type protoSegment struct {
|
type protoSegment struct {
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
addr "github.com/libp2p/go-libp2p-peerstore/addr"
|
addr "github.com/libp2p/go-libp2p-peerstore/addr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package pstoremem
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
pt "github.com/libp2p/go-libp2p-peerstore/test"
|
pt "github.com/libp2p/go-libp2p-peerstore/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-crypto"
|
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type memoryKeyBook struct {
|
type memoryKeyBook struct {
|
||||||
|
@ -3,8 +3,8 @@ package pstoremem
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var internKeys = map[string]bool{
|
var internKeys = map[string]bool{
|
||||||
|
@ -3,9 +3,9 @@ package pstoremem
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type protoSegment struct {
|
type protoSegment struct {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
ks "github.com/whyrusleeping/go-keyspace"
|
ks "github.com/whyrusleeping/go-keyspace"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package queue
|
package queue
|
||||||
|
|
||||||
import "github.com/libp2p/go-libp2p-peer"
|
import "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
// PeerQueue maintains a set of peers ordered according to a metric.
|
// PeerQueue maintains a set of peers ordered according to a metric.
|
||||||
// Implementations of PeerQueue could order peers based on distances along
|
// Implementations of PeerQueue could order peers based on distances along
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
"github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("peerqueue")
|
var log = logging.Logger("peerqueue")
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var addressBookSuite = map[string]func(book pstore.AddrBook) func(*testing.T){
|
var addressBookSuite = map[string]func(book pstore.AddrBook) func(*testing.T){
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var peerstoreBenchmarks = map[string]func(pstore.Peerstore, chan *peerpair) func(*testing.B){
|
var peerstoreBenchmarks = map[string]func(pstore.Peerstore, chan *peerpair) func(*testing.B){
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
ic "github.com/libp2p/go-libp2p-crypto"
|
ic "github.com/libp2p/go-libp2p-core/crypto"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pt "github.com/libp2p/go-libp2p-peer/test"
|
pt "github.com/libp2p/go-libp2p-core/test"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var keyBookSuite = map[string]func(kb pstore.KeyBook) func(*testing.T){
|
var keyBookSuite = map[string]func(kb pstore.KeyBook) func(*testing.T){
|
||||||
@ -41,7 +41,7 @@ func testKeybookPrivKey(kb pstore.KeyBook) func(t *testing.T) {
|
|||||||
t.Error("expected peers to be empty on init")
|
t.Error("expected peers to be empty on init")
|
||||||
}
|
}
|
||||||
|
|
||||||
priv, _, err := pt.RandTestKeyPair(512)
|
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ func testKeyBookPubKey(kb pstore.KeyBook) func(t *testing.T) {
|
|||||||
t.Error("expected peers to be empty on init")
|
t.Error("expected peers to be empty on init")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, pub, err := pt.RandTestKeyPair(512)
|
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@ -114,12 +114,12 @@ func testKeyBookPeers(kb pstore.KeyBook) func(t *testing.T) {
|
|||||||
var peers peer.IDSlice
|
var peers peer.IDSlice
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
// Add a public key.
|
// Add a public key.
|
||||||
_, pub, _ := pt.RandTestKeyPair(512)
|
_, pub, _ := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
p1, _ := peer.IDFromPublicKey(pub)
|
p1, _ := peer.IDFromPublicKey(pub)
|
||||||
kb.AddPubKey(p1, pub)
|
kb.AddPubKey(p1, pub)
|
||||||
|
|
||||||
// Add a private key.
|
// Add a private key.
|
||||||
priv, _, _ := pt.RandTestKeyPair(512)
|
priv, _, _ := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
p2, _ := peer.IDFromPrivateKey(priv)
|
p2, _ := peer.IDFromPrivateKey(priv)
|
||||||
kb.AddPrivKey(p2, priv)
|
kb.AddPrivKey(p2, priv)
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ func BenchmarkKeyBook(b *testing.B, factory KeyBookFactory) {
|
|||||||
|
|
||||||
func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) {
|
func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) {
|
||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
_, pub, err := pt.RandTestKeyPair(512)
|
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ func benchmarkPubKey(kb pstore.KeyBook) func(*testing.B) {
|
|||||||
|
|
||||||
func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) {
|
func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) {
|
||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
_, pub, err := pt.RandTestKeyPair(512)
|
_, pub, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ func benchmarkAddPubKey(kb pstore.KeyBook) func(*testing.B) {
|
|||||||
|
|
||||||
func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
priv, _, err := pt.RandTestKeyPair(512)
|
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ func benchmarkPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
|||||||
|
|
||||||
func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
priv, _, err := pt.RandTestKeyPair(512)
|
priv, _, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ func benchmarkAddPrivKey(kb pstore.KeyBook) func(*testing.B) {
|
|||||||
func benchmarkPeersWithKeys(kb pstore.KeyBook) func(*testing.B) {
|
func benchmarkPeersWithKeys(kb pstore.KeyBook) func(*testing.B) {
|
||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
priv, pub, err := pt.RandTestKeyPair(512)
|
priv, pub, err := pt.RandTestKeyPair(ic.RSA, 512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
crypto "github.com/libp2p/go-libp2p-crypto"
|
"github.com/libp2p/go-libp2p-core/crypto"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
|
|
||||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
pstore "github.com/libp2p/go-libp2p-core/peerstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
var peerstoreSuite = map[string]func(pstore.Peerstore) func(*testing.T){
|
var peerstoreSuite = map[string]func(pstore.Peerstore) func(*testing.T){
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
pt "github.com/libp2p/go-libp2p-peer/test"
|
pt "github.com/libp2p/go-libp2p-core/test"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user