Consolidate abstractions and core types into go-libp2p-core (#601)

This commit is contained in:
Raúl Kripalani
2019-05-26 22:55:46 +01:00
committed by GitHub
parent 6813fdd0d1
commit d87f89314c
39 changed files with 544 additions and 538 deletions

View File

@@ -4,24 +4,26 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/pnet"
"github.com/libp2p/go-libp2p-core/routing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
relay "github.com/libp2p/go-libp2p/p2p/host/relay" relay "github.com/libp2p/go-libp2p/p2p/host/relay"
routed "github.com/libp2p/go-libp2p/p2p/host/routed" routed "github.com/libp2p/go-libp2p/p2p/host/routed"
logging "github.com/ipfs/go-log"
circuit "github.com/libp2p/go-libp2p-circuit" circuit "github.com/libp2p/go-libp2p-circuit"
crypto "github.com/libp2p/go-libp2p-crypto"
discovery "github.com/libp2p/go-libp2p-discovery" discovery "github.com/libp2p/go-libp2p-discovery"
host "github.com/libp2p/go-libp2p-host"
ifconnmgr "github.com/libp2p/go-libp2p-interface-connmgr"
pnet "github.com/libp2p/go-libp2p-interface-pnet"
metrics "github.com/libp2p/go-libp2p-metrics"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
routing "github.com/libp2p/go-libp2p-routing"
swarm "github.com/libp2p/go-libp2p-swarm" swarm "github.com/libp2p/go-libp2p-swarm"
tptu "github.com/libp2p/go-libp2p-transport-upgrader" tptu "github.com/libp2p/go-libp2p-transport-upgrader"
logging "github.com/ipfs/go-log"
filter "github.com/libp2p/go-maddr-filter" filter "github.com/libp2p/go-maddr-filter"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -33,7 +35,7 @@ var log = logging.Logger("p2p-config")
type AddrsFactory = bhost.AddrsFactory type AddrsFactory = bhost.AddrsFactory
// NATManagerC is a NATManager constructor. // NATManagerC is a NATManager constructor.
type NATManagerC func(inet.Network) bhost.NATManager type NATManagerC func(network.Network) bhost.NATManager
type RoutingC func(host.Host) (routing.PeerRouting, error) type RoutingC func(host.Host) (routing.PeerRouting, error)
@@ -58,9 +60,9 @@ type Config struct {
AddrsFactory bhost.AddrsFactory AddrsFactory bhost.AddrsFactory
Filters *filter.Filters Filters *filter.Filters
ConnManager ifconnmgr.ConnManager ConnManager connmgr.ConnManager
NATManager NATManagerC NATManager NATManagerC
Peerstore pstore.Peerstore Peerstore peerstore.Peerstore
Reporter metrics.Reporter Reporter metrics.Reporter
DisablePing bool DisablePing bool

View File

@@ -4,30 +4,31 @@ import (
"fmt" "fmt"
"reflect" "reflect"
security "github.com/libp2p/go-conn-security" "github.com/libp2p/go-libp2p-core/crypto"
crypto "github.com/libp2p/go-libp2p-crypto" "github.com/libp2p/go-libp2p-core/host"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/mux"
pnet "github.com/libp2p/go-libp2p-interface-pnet" "github.com/libp2p/go-libp2p-core/network"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/peer"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peerstore"
pstore "github.com/libp2p/go-libp2p-peerstore" "github.com/libp2p/go-libp2p-core/pnet"
transport "github.com/libp2p/go-libp2p-transport" "github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/transport"
tptu "github.com/libp2p/go-libp2p-transport-upgrader" tptu "github.com/libp2p/go-libp2p-transport-upgrader"
filter "github.com/libp2p/go-maddr-filter" filter "github.com/libp2p/go-maddr-filter"
mux "github.com/libp2p/go-stream-muxer"
) )
var ( var (
// interfaces // interfaces
hostType = reflect.TypeOf((*host.Host)(nil)).Elem() hostType = reflect.TypeOf((*host.Host)(nil)).Elem()
networkType = reflect.TypeOf((*inet.Network)(nil)).Elem() networkType = reflect.TypeOf((*network.Network)(nil)).Elem()
transportType = reflect.TypeOf((*transport.Transport)(nil)).Elem() transportType = reflect.TypeOf((*transport.Transport)(nil)).Elem()
muxType = reflect.TypeOf((*mux.Transport)(nil)).Elem() muxType = reflect.TypeOf((*mux.Multiplexer)(nil)).Elem()
securityType = reflect.TypeOf((*security.Transport)(nil)).Elem() securityType = reflect.TypeOf((*sec.SecureTransport)(nil)).Elem()
protectorType = reflect.TypeOf((*pnet.Protector)(nil)).Elem() protectorType = reflect.TypeOf((*pnet.Protector)(nil)).Elem()
privKeyType = reflect.TypeOf((*crypto.PrivKey)(nil)).Elem() privKeyType = reflect.TypeOf((*crypto.PrivKey)(nil)).Elem()
pubKeyType = reflect.TypeOf((*crypto.PubKey)(nil)).Elem() pubKeyType = reflect.TypeOf((*crypto.PubKey)(nil)).Elem()
pstoreType = reflect.TypeOf((*pstore.Peerstore)(nil)).Elem() pstoreType = reflect.TypeOf((*peerstore.Peerstore)(nil)).Elem()
// concrete types // concrete types
peerIDType = reflect.TypeOf((peer.ID)("")) peerIDType = reflect.TypeOf((peer.ID)(""))

View File

@@ -3,13 +3,13 @@ package config
import ( import (
"fmt" "fmt"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
mux "github.com/libp2p/go-stream-muxer" "github.com/libp2p/go-libp2p-core/mux"
msmux "github.com/libp2p/go-stream-muxer-multistream" msmux "github.com/libp2p/go-stream-muxer-multistream"
) )
// MuxC is a stream multiplex transport constructor // MuxC is a stream multiplex transport constructor
type MuxC func(h host.Host) (mux.Transport, error) type MuxC func(h host.Host) (mux.Multiplexer, error)
// MsMuxC is a tuple containing a multiplex transport constructor and a protocol // MsMuxC is a tuple containing a multiplex transport constructor and a protocol
// ID. // ID.
@@ -24,8 +24,8 @@ var muxArgTypes = newArgTypeSet(hostType, networkType, peerIDType, pstoreType)
// using reflection. // using reflection.
func MuxerConstructor(m interface{}) (MuxC, error) { func MuxerConstructor(m interface{}) (MuxC, error) {
// Already constructed? // Already constructed?
if t, ok := m.(mux.Transport); ok { if t, ok := m.(mux.Multiplexer); ok {
return func(_ host.Host) (mux.Transport, error) { return func(_ host.Host) (mux.Multiplexer, error) {
return t, nil return t, nil
}, nil }, nil
} }
@@ -34,16 +34,16 @@ func MuxerConstructor(m interface{}) (MuxC, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return func(h host.Host) (mux.Transport, error) { return func(h host.Host) (mux.Multiplexer, error) {
t, err := ctor(h, nil) t, err := ctor(h, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return t.(mux.Transport), nil return t.(mux.Multiplexer), nil
}, nil }, nil
} }
func makeMuxer(h host.Host, tpts []MsMuxC) (mux.Transport, error) { func makeMuxer(h host.Host, tpts []MsMuxC) (mux.Multiplexer, error) {
muxMuxer := msmux.NewBlankTransport() muxMuxer := msmux.NewBlankTransport()
transportSet := make(map[string]struct{}, len(tpts)) transportSet := make(map[string]struct{}, len(tpts))
for _, tptC := range tpts { for _, tptC := range tpts {

View File

@@ -4,17 +4,18 @@ import (
"context" "context"
"testing" "testing"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
yamux "github.com/libp2p/go-libp2p-yamux"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
mux "github.com/libp2p/go-stream-muxer"
mux "github.com/libp2p/go-libp2p-core/mux"
yamux "github.com/libp2p/go-libp2p-yamux"
) )
func TestMuxerSimple(t *testing.T) { func TestMuxerSimple(t *testing.T) {
// single // single
_, err := MuxerConstructor(func(_ peer.ID) mux.Transport { return nil }) _, err := MuxerConstructor(func(_ peer.ID) mux.Multiplexer { return nil })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -27,14 +28,14 @@ func TestMuxerByValue(t *testing.T) {
} }
} }
func TestMuxerDuplicate(t *testing.T) { func TestMuxerDuplicate(t *testing.T) {
_, err := MuxerConstructor(func(_ peer.ID, _ peer.ID) mux.Transport { return nil }) _, err := MuxerConstructor(func(_ peer.ID, _ peer.ID) mux.Multiplexer { return nil })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestMuxerError(t *testing.T) { func TestMuxerError(t *testing.T) {
_, err := MuxerConstructor(func() (mux.Transport, error) { return nil, nil }) _, err := MuxerConstructor(func() (mux.Multiplexer, error) { return nil, nil })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -45,8 +46,8 @@ func TestMuxerBadTypes(t *testing.T) {
func() error { return nil }, func() error { return nil },
func() string { return "" }, func() string { return "" },
func() {}, func() {},
func(string) mux.Transport { return nil }, func(string) mux.Multiplexer { return nil },
func(string) (mux.Transport, error) { return nil, nil }, func(string) (mux.Multiplexer, error) { return nil, nil },
nil, nil,
"testing", "testing",
} { } {

View File

@@ -5,7 +5,7 @@ import (
"reflect" "reflect"
"runtime" "runtime"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
tptu "github.com/libp2p/go-libp2p-transport-upgrader" tptu "github.com/libp2p/go-libp2p-transport-upgrader"
) )

View File

@@ -3,15 +3,16 @@ package config
import ( import (
"fmt" "fmt"
security "github.com/libp2p/go-conn-security" "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/sec/insecure"
csms "github.com/libp2p/go-conn-security-multistream" csms "github.com/libp2p/go-conn-security-multistream"
insecure "github.com/libp2p/go-conn-security/insecure"
host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
) )
// SecC is a security transport constructor // SecC is a security transport constructor
type SecC func(h host.Host) (security.Transport, error) type SecC func(h host.Host) (sec.SecureTransport, error)
// MsSecC is a tuple containing a security transport constructor and a protocol // MsSecC is a tuple containing a security transport constructor and a protocol
// ID. // ID.
@@ -27,34 +28,34 @@ var securityArgTypes = newArgTypeSet(
// SecurityConstructor creates a security constructor from the passed parameter // SecurityConstructor creates a security constructor from the passed parameter
// using reflection. // using reflection.
func SecurityConstructor(sec interface{}) (SecC, error) { func SecurityConstructor(security interface{}) (SecC, error) {
// Already constructed? // Already constructed?
if t, ok := sec.(security.Transport); ok { if t, ok := security.(sec.SecureTransport); ok {
return func(_ host.Host) (security.Transport, error) { return func(_ host.Host) (sec.SecureTransport, error) {
return t, nil return t, nil
}, nil }, nil
} }
ctor, err := makeConstructor(sec, securityType, securityArgTypes) ctor, err := makeConstructor(security, securityType, securityArgTypes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return func(h host.Host) (security.Transport, error) { return func(h host.Host) (sec.SecureTransport, error) {
t, err := ctor(h, nil) t, err := ctor(h, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return t.(security.Transport), nil return t.(sec.SecureTransport), nil
}, nil }, nil
} }
func makeInsecureTransport(id peer.ID) security.Transport { func makeInsecureTransport(id peer.ID) sec.SecureTransport {
secMuxer := new(csms.SSMuxer) secMuxer := new(csms.SSMuxer)
secMuxer.AddTransport(insecure.ID, insecure.New(id)) secMuxer.AddTransport(insecure.ID, insecure.New(id))
return secMuxer return secMuxer
} }
func makeSecurityTransport(h host.Host, tpts []MsSecC) (security.Transport, error) { func makeSecurityTransport(h host.Host, tpts []MsSecC) (sec.SecureTransport, error) {
secMuxer := new(csms.SSMuxer) secMuxer := new(csms.SSMuxer)
transportSet := make(map[string]struct{}, len(tpts)) transportSet := make(map[string]struct{}, len(tpts))
for _, tptC := range tpts { for _, tptC := range tpts {

View File

@@ -1,8 +1,9 @@
package config package config
import ( import (
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
transport "github.com/libp2p/go-libp2p-transport" "github.com/libp2p/go-libp2p-core/transport"
tptu "github.com/libp2p/go-libp2p-transport-upgrader" tptu "github.com/libp2p/go-libp2p-transport-upgrader"
) )

View File

@@ -5,7 +5,7 @@ package libp2p
import ( import (
"crypto/rand" "crypto/rand"
crypto "github.com/libp2p/go-libp2p-crypto" crypto "github.com/libp2p/go-libp2p-core/crypto"
mplex "github.com/libp2p/go-libp2p-mplex" mplex "github.com/libp2p/go-libp2p-mplex"
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem" pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
secio "github.com/libp2p/go-libp2p-secio" secio "github.com/libp2p/go-libp2p-secio"

49
go.mod
View File

@@ -8,41 +8,30 @@ require (
github.com/ipfs/go-log v0.0.1 github.com/ipfs/go-log v0.0.1
github.com/jbenet/go-cienv v0.1.0 github.com/jbenet/go-cienv v0.1.0
github.com/jbenet/goprocess v0.1.3 github.com/jbenet/goprocess v0.1.3
github.com/libp2p/go-conn-security v0.0.1 github.com/libp2p/go-conn-security-multistream v0.1.0
github.com/libp2p/go-conn-security-multistream v0.0.2 github.com/libp2p/go-libp2p-autonat v0.1.0
github.com/libp2p/go-libp2p-autonat v0.0.6 github.com/libp2p/go-libp2p-blankhost v0.1.1
github.com/libp2p/go-libp2p-blankhost v0.0.1 github.com/libp2p/go-libp2p-circuit v0.1.0
github.com/libp2p/go-libp2p-circuit v0.0.9 github.com/libp2p/go-libp2p-core v0.0.1
github.com/libp2p/go-libp2p-crypto v0.0.2 github.com/libp2p/go-libp2p-discovery v0.1.0
github.com/libp2p/go-libp2p-discovery v0.0.5 github.com/libp2p/go-libp2p-loggables v0.1.0
github.com/libp2p/go-libp2p-host v0.0.3 github.com/libp2p/go-libp2p-mplex v0.2.1
github.com/libp2p/go-libp2p-interface-connmgr v0.0.5
github.com/libp2p/go-libp2p-interface-pnet v0.0.1
github.com/libp2p/go-libp2p-loggables v0.0.1
github.com/libp2p/go-libp2p-metrics v0.0.1
github.com/libp2p/go-libp2p-mplex v0.1.1
github.com/libp2p/go-libp2p-nat v0.0.4 github.com/libp2p/go-libp2p-nat v0.0.4
github.com/libp2p/go-libp2p-net v0.0.2 github.com/libp2p/go-libp2p-netutil v0.1.0
github.com/libp2p/go-libp2p-netutil v0.0.1 github.com/libp2p/go-libp2p-peerstore v0.1.0
github.com/libp2p/go-libp2p-peer v0.1.1 github.com/libp2p/go-libp2p-secio v0.1.0
github.com/libp2p/go-libp2p-peerstore v0.0.6 github.com/libp2p/go-libp2p-swarm v0.1.0
github.com/libp2p/go-libp2p-protocol v0.0.1 github.com/libp2p/go-libp2p-testing v0.0.3
github.com/libp2p/go-libp2p-routing v0.0.1 github.com/libp2p/go-libp2p-transport-upgrader v0.1.1
github.com/libp2p/go-libp2p-secio v0.0.3 github.com/libp2p/go-libp2p-yamux v0.2.0
github.com/libp2p/go-libp2p-swarm v0.0.6
github.com/libp2p/go-libp2p-transport v0.0.5
github.com/libp2p/go-libp2p-transport-upgrader v0.0.4
github.com/libp2p/go-libp2p-yamux v0.1.2
github.com/libp2p/go-maddr-filter v0.0.4 github.com/libp2p/go-maddr-filter v0.0.4
github.com/libp2p/go-stream-muxer v0.0.1 github.com/libp2p/go-stream-muxer-multistream v0.2.0
github.com/libp2p/go-stream-muxer-multistream v0.1.1 github.com/libp2p/go-tcp-transport v0.1.0
github.com/libp2p/go-tcp-transport v0.0.4 github.com/libp2p/go-ws-transport v0.1.0
github.com/libp2p/go-testutil v0.0.1
github.com/libp2p/go-ws-transport v0.0.5
github.com/miekg/dns v1.1.12 // indirect github.com/miekg/dns v1.1.12 // indirect
github.com/multiformats/go-multiaddr v0.0.4 github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-dns v0.0.2 github.com/multiformats/go-multiaddr-dns v0.0.2
github.com/multiformats/go-multiaddr-net v0.0.1 github.com/multiformats/go-multiaddr-net v0.0.1
github.com/multiformats/go-multistream v0.0.4 github.com/multiformats/go-multistream v0.1.0
github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30 github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30
) )

151
go.sum
View File

@@ -10,9 +10,8 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.2.1-0.20180108230905-e214231b295a h1:U0BbGfKnviqVBJQB4etvm+mKx53KfkumNLBt6YeF/0Q= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.2.1-0.20180108230905-e214231b295a/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -32,7 +31,9 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gxed/hashland/keccakpg v0.0.1 h1:wrk3uMNaMxbXiHibbPO4S0ymqJMm41WiudyFSs7UnsU=
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
github.com/gxed/hashland/murmur3 v0.0.1 h1:SheiaIt0sda5K+8FLz952/1iWS9zrnKsEJaOJu4ZbSc=
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
@@ -82,71 +83,51 @@ github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpz
github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ=
github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs=
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
github.com/libp2p/go-conn-security v0.0.1 h1:4kMMrqrt9EUNCNjX1xagSJC+bq16uqjMe9lk1KBMVNs= github.com/libp2p/go-conn-security-multistream v0.1.0 h1:aqGmto+ttL/uJgX0JtQI0tD21CIEy5eYd1Hlp0juHY0=
github.com/libp2p/go-conn-security v0.0.1/go.mod h1:bGmu51N0KU9IEjX7kl2PQjgZa40JQWnayTvNMgD/vyk= github.com/libp2p/go-conn-security-multistream v0.1.0/go.mod h1:aw6eD7LOsHEX7+2hJkDxw1MteijaVcI+/eP2/x3J1xc=
github.com/libp2p/go-conn-security-multistream v0.0.2 h1:Ykz0lnNjxk+0SdslUmlLNyrleqdpS1S/VW+dxFdt74Y=
github.com/libp2p/go-conn-security-multistream v0.0.2/go.mod h1:nc9vud7inQ+d6SO0I/6dSWrdMnHnzZNHeyUQqrAJulE=
github.com/libp2p/go-flow-metrics v0.0.1 h1:0gxuFd2GuK7IIP5pKljLwps6TvcuYgvG7Atqi3INF5s= github.com/libp2p/go-flow-metrics v0.0.1 h1:0gxuFd2GuK7IIP5pKljLwps6TvcuYgvG7Atqi3INF5s=
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-autonat v0.0.6 h1:OCStANLLpeyQeWFUuqZJ7aS9+Bx0/uoVb1PtLA9fGTQ= github.com/libp2p/go-libp2p-autonat v0.1.0 h1:aCWAu43Ri4nU0ZPO7NyLzUvvfqd0nE3dX0R/ZGYVgOU=
github.com/libp2p/go-libp2p-autonat v0.0.6/go.mod h1:uZneLdOkZHro35xIhpbtTzLlgYturpu4J5+0cZK3MqE= github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8=
github.com/libp2p/go-libp2p-blankhost v0.0.1 h1:/mZuuiwntNR8RywnCFlGHLKrKLYne+qciBpQXWqp5fk= github.com/libp2p/go-libp2p-blankhost v0.1.1 h1:X919sCh+KLqJcNRApj43xCSiQRYqOSI88Fdf55ngf78=
github.com/libp2p/go-libp2p-blankhost v0.0.1/go.mod h1:Ibpbw/7cPPYwFb7PACIWdvxxv0t0XCCI10t7czjAjTc= github.com/libp2p/go-libp2p-blankhost v0.1.1/go.mod h1:pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro=
github.com/libp2p/go-libp2p-circuit v0.0.9 h1:tjdgP9hv8+Pa/xsprBpEFngq4t8aLvjfibBYoDjO9i4= github.com/libp2p/go-libp2p-circuit v0.1.0 h1:eniLL3Y9aq/sryfyV1IAHj5rlvuyj3b7iz8tSiZpdhY=
github.com/libp2p/go-libp2p-circuit v0.0.9/go.mod h1:uU+IBvEQzCu953/ps7bYzC/D/R0Ho2A9LfKVVCatlqU= github.com/libp2p/go-libp2p-circuit v0.1.0/go.mod h1:Ahq4cY3V9VJcHcn1SBXjr78AbFkZeIRmfunbA7pmFh8=
github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-core v0.0.1 h1:HSTZtFIq/W5Ue43Zw+uWZyy2Vl5WtF0zDjKN8/DT/1I=
github.com/libp2p/go-libp2p-crypto v0.0.2 h1:TTdJ4y6Uoa6NxQcuEaVkQfFRcQeCE2ReDk8Ok4I0Fyw= github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco=
github.com/libp2p/go-libp2p-crypto v0.0.2/go.mod h1:eETI5OUfBnvARGOHrJz2eWNyTUxEGZnBxMcbUjfIj4I= github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ=
github.com/libp2p/go-libp2p-discovery v0.0.5 h1:VpPd7u2odnrrRcW+gVdjLDcXsc35k0Tjxqgbzlre6Uo= github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI=
github.com/libp2p/go-libp2p-discovery v0.0.5/go.mod h1:YtF20GUxjgoKZ4zmXj8j3Nb2TUSBHFlOCetzYdbZL5I= github.com/libp2p/go-libp2p-discovery v0.1.0 h1:j+R6cokKcGbnZLf4kcNwpx6mDEUPF3N6SrqMymQhmvs=
github.com/libp2p/go-libp2p-host v0.0.1/go.mod h1:qWd+H1yuU0m5CwzAkvbSjqKairayEHdR5MMl7Cwa7Go= github.com/libp2p/go-libp2p-discovery v0.1.0/go.mod h1:4F/x+aldVHjHDHuX85x1zWoFTGElt8HnoDzwkFZm29g=
github.com/libp2p/go-libp2p-host v0.0.3 h1:BB/1Z+4X0rjKP5lbQTmjEjLbDVbrcmLOlA6QDsN5/j4= github.com/libp2p/go-libp2p-loggables v0.1.0 h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8=
github.com/libp2p/go-libp2p-host v0.0.3/go.mod h1:Y/qPyA6C8j2coYyos1dfRm0I8+nvd4TGrDGt4tA7JR8= github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90=
github.com/libp2p/go-libp2p-interface-connmgr v0.0.1/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= github.com/libp2p/go-libp2p-mplex v0.2.0/go.mod h1:Ejl9IyjvXJ0T9iqUTE1jpYATQ9NM3g+OtR+EMMODbKo=
github.com/libp2p/go-libp2p-interface-connmgr v0.0.4/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= github.com/libp2p/go-libp2p-mplex v0.2.1 h1:E1xaJBQnbSiTHGI1gaBKmKhu1TUKkErKJnE8iGvirYI=
github.com/libp2p/go-libp2p-interface-connmgr v0.0.5 h1:KG/KNYL2tYzXAfMvQN5K1aAGTYSYUMJ1prgYa2/JI1E= github.com/libp2p/go-libp2p-mplex v0.2.1/go.mod h1:SC99Rxs8Vuzrf/6WhmH41kNn13TiYdAWNYHrwImKLnE=
github.com/libp2p/go-libp2p-interface-connmgr v0.0.5/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k=
github.com/libp2p/go-libp2p-interface-pnet v0.0.1 h1:7GnzRrBTJHEsofi1ahFdPN9Si6skwXQE9UqR2S+Pkh8=
github.com/libp2p/go-libp2p-interface-pnet v0.0.1/go.mod h1:el9jHpQAXK5dnTpKA4yfCNBZXvrzdOU75zz+C6ryp3k=
github.com/libp2p/go-libp2p-loggables v0.0.1 h1:HVww9oAnINIxbt69LJNkxD8lnbfgteXR97Xm4p3l9ps=
github.com/libp2p/go-libp2p-loggables v0.0.1/go.mod h1:lDipDlBNYbpyqyPX/KcoO+eq0sJYEVR2JgOexcivchg=
github.com/libp2p/go-libp2p-metrics v0.0.1 h1:yumdPC/P2VzINdmcKZd0pciSUCpou+s0lwYCjBbzQZU=
github.com/libp2p/go-libp2p-metrics v0.0.1/go.mod h1:jQJ95SXXA/K1VZi13h52WZMa9ja78zjyy5rspMsC/08=
github.com/libp2p/go-libp2p-mplex v0.1.1 h1:lSPS1VJ36P01gGO//KgcsmSah5uoC3X9r7WY5j+iP4c=
github.com/libp2p/go-libp2p-mplex v0.1.1/go.mod h1:KUQWpGkCzfV7UIpi8SKsAVxyBgz1c9R5EvxgnwLsb/I=
github.com/libp2p/go-libp2p-nat v0.0.4 h1:+KXK324yaY701On8a0aGjTnw8467kW3ExKcqW2wwmyw= github.com/libp2p/go-libp2p-nat v0.0.4 h1:+KXK324yaY701On8a0aGjTnw8467kW3ExKcqW2wwmyw=
github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY= github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY=
github.com/libp2p/go-libp2p-net v0.0.1/go.mod h1:Yt3zgmlsHOgUWSXmt5V/Jpz9upuJBE8EgNU9DrCcR8c= github.com/libp2p/go-libp2p-netutil v0.1.0 h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLKcKF72EAMQ=
github.com/libp2p/go-libp2p-net v0.0.2 h1:qP06u4TYXfl7uW/hzqPhlVVTSA2nw1B/bHBJaUnbh6M= github.com/libp2p/go-libp2p-netutil v0.1.0/go.mod h1:3Qv/aDqtMLTUyQeundkKsA+YCThNdbQD54k3TqjpbFU=
github.com/libp2p/go-libp2p-net v0.0.2/go.mod h1:Yt3zgmlsHOgUWSXmt5V/Jpz9upuJBE8EgNU9DrCcR8c= github.com/libp2p/go-libp2p-peer v0.2.0 h1:EQ8kMjaCUwt/Y5uLgjT8iY2qg0mGUT0N1zUjer50DsY=
github.com/libp2p/go-libp2p-netutil v0.0.1 h1:LgD6+skofkOx8z6odD9+MZHKjupv3ng1u6KRhaADTnA= github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY=
github.com/libp2p/go-libp2p-netutil v0.0.1/go.mod h1:GdusFvujWZI9Vt0X5BKqwWWmZFxecf9Gt03cKxm2f/Q= github.com/libp2p/go-libp2p-peerstore v0.1.0 h1:MKh7pRNPHSh1fLPj8u/M/s/napdmeNpoi9BRy9lPN0E=
github.com/libp2p/go-libp2p-peer v0.0.1/go.mod h1:nXQvOBbwVqoP+T5Y5nCjeH4sP9IX/J0AMzcDUVruVoo= github.com/libp2p/go-libp2p-peerstore v0.1.0/go.mod h1:2CeHkQsr8svp4fZ+Oi9ykN1HBb6u0MOvdJ7YIsmcwtY=
github.com/libp2p/go-libp2p-peer v0.1.1 h1:qGCWD1a+PyZcna6htMPo26jAtqirVnJ5NvBQIKV7rRY= github.com/libp2p/go-libp2p-secio v0.1.0 h1:NNP5KLxuP97sE5Bu3iuwOWyT/dKEGMN5zSLMWdB7GTQ=
github.com/libp2p/go-libp2p-peer v0.1.1/go.mod h1:jkF12jGB4Gk/IOo+yomm+7oLWxF278F7UnrYUQ1Q8es= github.com/libp2p/go-libp2p-secio v0.1.0/go.mod h1:tMJo2w7h3+wN4pgU2LSYeiKPrfqBgkOsdiKK77hE7c8=
github.com/libp2p/go-libp2p-peerstore v0.0.1/go.mod h1:RabLyPVJLuNQ+GFyoEkfi8H4Ti6k/HtZJ7YKgtSq+20= github.com/libp2p/go-libp2p-swarm v0.1.0 h1:HrFk2p0awrGEgch9JXK/qp/hfjqQfgNxpLWnCiWPg5s=
github.com/libp2p/go-libp2p-peerstore v0.0.6 h1:RgX/djPFXqZGktW0j2eF4NAX0pzDsCot45jO2GewC+g= github.com/libp2p/go-libp2p-swarm v0.1.0/go.mod h1:wQVsCdjsuZoc730CgOvh5ox6K8evllckjebkdiY5ta4=
github.com/libp2p/go-libp2p-peerstore v0.0.6/go.mod h1:RabLyPVJLuNQ+GFyoEkfi8H4Ti6k/HtZJ7YKgtSq+20= github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-protocol v0.0.1 h1:+zkEmZ2yFDi5adpVE3t9dqh/N9TbpFWywowzeEzBbLM= github.com/libp2p/go-libp2p-testing v0.0.3 h1:bdij4bKaaND7tCsaXVjRfYkMpvoOeKj9AVQGJllA6jM=
github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1VZNHYcK8cLgFJLZ4s= github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-routing v0.0.1 h1:hPMAWktf9rYi3ME4MG48qE7dq1ofJxiQbfdvpNntjhc= github.com/libp2p/go-libp2p-transport-upgrader v0.1.1 h1:PZMS9lhjK9VytzMCW3tWHAXtKXmlURSc3ZdvwEcKCzw=
github.com/libp2p/go-libp2p-routing v0.0.1/go.mod h1:N51q3yTr4Zdr7V8Jt2JIktVU+3xBBylx1MZeVA6t1Ys= github.com/libp2p/go-libp2p-transport-upgrader v0.1.1/go.mod h1:IEtA6or8JUbsV07qPW4r01GnTenLW4oi3lOPbUMGJJA=
github.com/libp2p/go-libp2p-secio v0.0.3 h1:h3fPeDrej7bvvARnC2oSjAfcLZOaS4REZKgWCRQNpE4= github.com/libp2p/go-libp2p-yamux v0.2.0 h1:TSPZ5cMMz/wdoYsye/wU1TE4G3LDGMoeEN0xgnCKU/I=
github.com/libp2p/go-libp2p-secio v0.0.3/go.mod h1:hS7HQ00MgLhRO/Wyu1bTX6ctJKhVpm+j2/S2A5UqYb0= github.com/libp2p/go-libp2p-yamux v0.2.0/go.mod h1:Db2gU+XfLpm6E4rG5uGCFX6uXA8MEXOxFcRoXUODaK8=
github.com/libp2p/go-libp2p-swarm v0.0.6 h1:gE0P/v2h+KEXtAi9YTw2UBOSODJ4m9VuuJ+ktc2LVUo=
github.com/libp2p/go-libp2p-swarm v0.0.6/go.mod h1:s5GZvzg9xXe8sbeESuFpjt8CJPTCa8mhEusweJqyFy8=
github.com/libp2p/go-libp2p-transport v0.0.1/go.mod h1:UzbUs9X+PHOSw7S3ZmeOxfnwaQY5vGDzZmKPod3N3tk=
github.com/libp2p/go-libp2p-transport v0.0.5 h1:pV6+UlRxyDpASSGD+60vMvdifSCby6JkJDfi+yUMHac=
github.com/libp2p/go-libp2p-transport v0.0.5/go.mod h1:StoY3sx6IqsP6XKoabsPnHCwqKXWUMWU7Rfcsubee/A=
github.com/libp2p/go-libp2p-transport-upgrader v0.0.4 h1:uGMOd14BL1oFlfb/cGfOxPjiTKBhzWV4aMjjoCF1Z1o=
github.com/libp2p/go-libp2p-transport-upgrader v0.0.4/go.mod h1:RGq+tupk+oj7PzL2kn/m1w6YXxcIAYJYeI90h6BGgUc=
github.com/libp2p/go-libp2p-yamux v0.1.2 h1:DgGItlrWi0j9y1OhRMC8qqL4zj2MEPWeKJTHb55R16Q=
github.com/libp2p/go-libp2p-yamux v0.1.2/go.mod h1:xUoV/RmYkg6BW/qGxA9XJyg+HzXFYkeXbnhjmnYzKp8=
github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q=
github.com/libp2p/go-maddr-filter v0.0.4 h1:hx8HIuuwk34KePddrp2mM5ivgPkZ09JH4AvsALRbFUs= github.com/libp2p/go-maddr-filter v0.0.4 h1:hx8HIuuwk34KePddrp2mM5ivgPkZ09JH4AvsALRbFUs=
github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q=
github.com/libp2p/go-mplex v0.0.3 h1:YiMaevQcZtFU6DmKIF8xEO0vaui5kM5HJ1V1xkWQv14=
github.com/libp2p/go-mplex v0.0.3/go.mod h1:pK5yMLmOoBR1pNCqDlA2GQrdAVTMkqFalaTWe7l4Yd0= github.com/libp2p/go-mplex v0.0.3/go.mod h1:pK5yMLmOoBR1pNCqDlA2GQrdAVTMkqFalaTWe7l4Yd0=
github.com/libp2p/go-mplex v0.1.0 h1:/nBTy5+1yRyY82YaO6HXQRnO5IAGsXTjEJaR3LdTPc0=
github.com/libp2p/go-mplex v0.1.0/go.mod h1:SXgmdki2kwCUlCCbfGLEgHjC4pFqhTp0ZoV6aiKgxDU=
github.com/libp2p/go-msgio v0.0.2 h1:ivPvEKHxmVkTClHzg6RXTYHqaJQ0V9cDbq+6lKb3UV0= github.com/libp2p/go-msgio v0.0.2 h1:ivPvEKHxmVkTClHzg6RXTYHqaJQ0V9cDbq+6lKb3UV0=
github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ=
github.com/libp2p/go-nat v0.0.3 h1:l6fKV+p0Xa354EqQOQP+d8CivdLM4kl5GxC1hSc/UeI= github.com/libp2p/go-nat v0.0.3 h1:l6fKV+p0Xa354EqQOQP+d8CivdLM4kl5GxC1hSc/UeI=
@@ -155,18 +136,15 @@ github.com/libp2p/go-reuseport v0.0.1 h1:7PhkfH73VXfPJYKQ6JwS5I/eVcoyYi9IMNGc6FW
github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA= github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA=
github.com/libp2p/go-reuseport-transport v0.0.2 h1:WglMwyXyBu61CMkjCCtnmqNqnjib0GIEjMiHTwR/KN4= github.com/libp2p/go-reuseport-transport v0.0.2 h1:WglMwyXyBu61CMkjCCtnmqNqnjib0GIEjMiHTwR/KN4=
github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs= github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs=
github.com/libp2p/go-stream-muxer v0.0.1 h1:Ce6e2Pyu+b5MC1k3eeFtAax0pW4gc6MosYSLV05UeLw=
github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14=
github.com/libp2p/go-stream-muxer-multistream v0.1.1 h1:DhHqb4nu1fQv/vQKeLAaZGmhLsUA4SF77IdYJiWE1d4= github.com/libp2p/go-stream-muxer-multistream v0.2.0 h1:714bRJ4Zy9mdhyTLJ+ZKiROmAFwUHpeRidG+q7LTQOg=
github.com/libp2p/go-stream-muxer-multistream v0.1.1/go.mod h1:zmGdfkQ1AzOECIAcccoL8L//laqawOsO03zX8Sa+eGw= github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc=
github.com/libp2p/go-tcp-transport v0.0.4 h1:2iRu994wCT/iEz62F+c60FUoSkijNEQ0q2Itc+79XlQ= github.com/libp2p/go-tcp-transport v0.1.0 h1:IGhowvEqyMFknOar4FWCKSWE0zL36UFKQtiRQD60/8o=
github.com/libp2p/go-tcp-transport v0.0.4/go.mod h1:+E8HvC8ezEVOxIo3V5vCK9l1y/19K427vCzQ+xHKH/o= github.com/libp2p/go-tcp-transport v0.1.0/go.mod h1:oJ8I5VXryj493DEJ7OsBieu8fcg2nHGctwtInJVpipc=
github.com/libp2p/go-testutil v0.0.1 h1:Xg+O0G2HIMfHqBOBDcMS1iSZJ3GEcId4qOxCQvsGZHk= github.com/libp2p/go-ws-transport v0.1.0 h1:F+0OvvdmPTDsVc4AjPHjV7L7Pk1B7D5QwtDcKE2oag4=
github.com/libp2p/go-testutil v0.0.1/go.mod h1:iAcJc/DKJQanJ5ws2V+u5ywdL2n12X1WbbEG+Jjy69I= github.com/libp2p/go-ws-transport v0.1.0/go.mod h1:rjw1MG1LU9YDC6gzmwObkPd/Sqwhw7yT74kj3raBFuo=
github.com/libp2p/go-ws-transport v0.0.5 h1:IHeR0X9nvE5hOdOD8X/FDQ6jIapdohToQseItwvpixU= github.com/libp2p/go-yamux v1.2.2 h1:s6J6o7+ajoQMjHe7BEnq+EynOj5D2EoG8CuQgL3F2vg=
github.com/libp2p/go-ws-transport v0.0.5/go.mod h1:Qbl4BxPfXXhhd/o0wcrgoaItHqA9tnZjoFZnxykuaXU= github.com/libp2p/go-yamux v1.2.2/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow=
github.com/libp2p/go-yamux v1.2.1 h1:VumHkMhJ2iFk1lzAeoDRgekiZSylGc6NnAEihVdBCiw=
github.com/libp2p/go-yamux v1.2.1/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow=
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=
@@ -175,35 +153,45 @@ github.com/miekg/dns v1.1.12 h1:WMhc1ik4LNkTg8U9l3hI1LvxKmIL+f1+WV/SZtCbDDA=
github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XCFOweFD3BNESdnO8ewyYTFT2R+/b8FQ=
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5 h1:l16XLUUJ34wIz+RIvLhSwGvLvKyy+W598b135bJN6mg=
github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/minio/sha256-simd v0.1.0 h1:U41/2erhAKcmSI14xh/ZTUdBPOzDOIfS93ibzUSl8KM=
github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78= github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78=
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY=
github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44=
github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44=
github.com/multiformats/go-multiaddr v0.0.4 h1:WgMSI84/eRLdbptXMkMWDXPjPq7SPLIgGUVm2eroyU4= github.com/multiformats/go-multiaddr v0.0.4 h1:WgMSI84/eRLdbptXMkMWDXPjPq7SPLIgGUVm2eroyU4=
github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44=
github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q=
github.com/multiformats/go-multiaddr-dns v0.0.2 h1:/Bbsgsy3R6e3jf2qBahzNHzww6usYaZ0NhNH3sqdFS8= github.com/multiformats/go-multiaddr-dns v0.0.2 h1:/Bbsgsy3R6e3jf2qBahzNHzww6usYaZ0NhNH3sqdFS8=
github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q=
github.com/multiformats/go-multiaddr-fmt v0.0.1 h1:5YjeOIzbX8OTKVaN72aOzGIYW7PnrZrnkDyOfAWRSMA=
github.com/multiformats/go-multiaddr-fmt v0.0.1/go.mod h1:aBYjqL4T/7j4Qx+R73XSv/8JsgnRFlf0w2KGLCmXl3Q=
github.com/multiformats/go-multiaddr-net v0.0.1 h1:76O59E3FavvHqNg7jvzWzsPSW5JSi/ek0E4eiDVbg9g= github.com/multiformats/go-multiaddr-net v0.0.1 h1:76O59E3FavvHqNg7jvzWzsPSW5JSi/ek0E4eiDVbg9g=
github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU= github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU=
github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA= github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA=
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPkegHMu2vDqQ=
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
github.com/multiformats/go-multihash v0.0.5 h1:1wxmCvTXAifAepIMyF39vZinRw5sbqjPs/UIi93+uik= github.com/multiformats/go-multihash v0.0.5 h1:1wxmCvTXAifAepIMyF39vZinRw5sbqjPs/UIi93+uik=
github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po= github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po=
github.com/multiformats/go-multistream v0.0.1/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= github.com/multiformats/go-multistream v0.1.0 h1:UpO6jrsjqs46mqAK3n6wKRYFhugss9ArzbyUzU+4wkQ=
github.com/multiformats/go-multistream v0.0.4 h1:rNgWgFyzRSTI9L+xISrz7kN5MdNXoEcoIeeCH05wLKA= github.com/multiformats/go-multistream v0.1.0/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg=
github.com/multiformats/go-multistream v0.0.4/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
@@ -232,14 +220,16 @@ github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30/go.mod h1:j4l84
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 h1:E9S12nwJwEOXe2d6gT6qxdvqMnNq+VnSsKPgm2ZZNds= github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 h1:E9S12nwJwEOXe2d6gT6qxdvqMnNq+VnSsKPgm2ZZNds=
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7/go.mod h1:X2c0RVCI1eSUFI8eLcY3c0423ykwiUdxLJtkDvruhjI= github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7/go.mod h1:X2c0RVCI1eSUFI8eLcY3c0423ykwiUdxLJtkDvruhjI=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190227160552-c95aed5357e7 h1:C2F/nMkR/9sfUTpvR3QrjBuTdvMUC/cFajkphs1YLQo=
golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -248,6 +238,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=

View File

@@ -5,7 +5,7 @@ import (
config "github.com/libp2p/go-libp2p/config" config "github.com/libp2p/go-libp2p/config"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
) )
// Config describes a set of settings for a libp2p node // Config describes a set of settings for a libp2p node

View File

@@ -7,9 +7,9 @@ import (
"strings" "strings"
"testing" "testing"
crypto "github.com/libp2p/go-libp2p-crypto" "github.com/libp2p/go-libp2p-core/crypto"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
pstore "github.com/libp2p/go-libp2p-peerstore" "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-tcp-transport" "github.com/libp2p/go-tcp-transport"
) )
@@ -59,7 +59,7 @@ func TestNoTransports(t *testing.T) {
} }
defer b.Close() defer b.Close()
err = a.Connect(ctx, pstore.PeerInfo{ err = a.Connect(ctx, peer.AddrInfo{
ID: b.ID(), ID: b.ID(),
Addrs: b.Addrs(), Addrs: b.Addrs(),
}) })

View File

@@ -7,15 +7,16 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/pnet"
circuit "github.com/libp2p/go-libp2p-circuit"
config "github.com/libp2p/go-libp2p/config" config "github.com/libp2p/go-libp2p/config"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
circuit "github.com/libp2p/go-libp2p-circuit"
crypto "github.com/libp2p/go-libp2p-crypto"
ifconnmgr "github.com/libp2p/go-libp2p-interface-connmgr"
pnet "github.com/libp2p/go-libp2p-interface-pnet"
metrics "github.com/libp2p/go-libp2p-metrics"
pstore "github.com/libp2p/go-libp2p-peerstore"
filter "github.com/libp2p/go-maddr-filter" filter "github.com/libp2p/go-maddr-filter"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -132,7 +133,7 @@ func Transport(tpt interface{}) Option {
} }
// Peerstore configures libp2p to use the given peerstore. // Peerstore configures libp2p to use the given peerstore.
func Peerstore(ps pstore.Peerstore) Option { func Peerstore(ps peerstore.Peerstore) Option {
return func(cfg *Config) error { return func(cfg *Config) error {
if cfg.Peerstore != nil { if cfg.Peerstore != nil {
return fmt.Errorf("cannot specify multiple peerstore options") return fmt.Errorf("cannot specify multiple peerstore options")
@@ -180,7 +181,7 @@ func Identity(sk crypto.PrivKey) Option {
} }
// ConnectionManager configures libp2p to use the given connection manager. // ConnectionManager configures libp2p to use the given connection manager.
func ConnectionManager(connman ifconnmgr.ConnManager) Option { func ConnectionManager(connman connmgr.ConnManager) Option {
return func(cfg *Config) error { return func(cfg *Config) error {
if cfg.ConnManager != nil { if cfg.ConnManager != nil {
return fmt.Errorf("cannot specify multiple connection managers") return fmt.Errorf("cannot specify multiple connection managers")

View File

@@ -8,10 +8,10 @@ import (
"sync" "sync"
"time" "time"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-host"
"github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net" manet "github.com/multiformats/go-multiaddr-net"
"github.com/whyrusleeping/mdns" "github.com/whyrusleeping/mdns"
@@ -33,7 +33,7 @@ type Service interface {
} }
type Notifee interface { type Notifee interface {
HandlePeerFound(pstore.PeerInfo) HandlePeerFound(peer.AddrInfo)
} }
type mdnsService struct { type mdnsService struct {
@@ -173,7 +173,7 @@ func (m *mdnsService) handleEntry(e *mdns.ServiceEntry) {
return return
} }
pi := pstore.PeerInfo{ pi := peer.AddrInfo{
ID: mpeer, ID: mpeer,
Addrs: []ma.Multiaddr{maddr}, Addrs: []ma.Multiaddr{maddr},
} }

View File

@@ -5,19 +5,18 @@ import (
"testing" "testing"
"time" "time"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
host "github.com/libp2p/go-libp2p-host"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
pstore "github.com/libp2p/go-libp2p-peerstore"
) )
type DiscoveryNotifee struct { type DiscoveryNotifee struct {
h host.Host h host.Host
} }
func (n *DiscoveryNotifee) HandlePeerFound(pi pstore.PeerInfo) { func (n *DiscoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
n.h.Connect(context.Background(), pi) n.h.Connect(context.Background(), pi)
} }
@@ -49,7 +48,7 @@ func TestMdnsDiscovery(t *testing.T) {
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
err = a.Connect(ctx, pstore.PeerInfo{ID: b.ID()}) err = a.Connect(ctx, peer.AddrInfo{ID: b.ID()})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -7,15 +7,19 @@ import (
"sync" "sync"
"time" "time"
"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/protocol"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
goprocess "github.com/jbenet/goprocess" goprocess "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
ifconnmgr "github.com/libp2p/go-libp2p-interface-connmgr"
inat "github.com/libp2p/go-libp2p-nat" inat "github.com/libp2p/go-libp2p-nat"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
protocol "github.com/libp2p/go-libp2p-protocol"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
ping "github.com/libp2p/go-libp2p/p2p/protocol/ping" ping "github.com/libp2p/go-libp2p/p2p/protocol/ping"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
@@ -58,13 +62,13 @@ const NATPortMap Option = iota
// * uses an identity service to send + receive node information // * uses an identity service to send + receive node information
// * uses a nat service to establish NAT port mappings // * uses a nat service to establish NAT port mappings
type BasicHost struct { type BasicHost struct {
network inet.Network network network.Network
mux *msmux.MultistreamMuxer mux *msmux.MultistreamMuxer
ids *identify.IDService ids *identify.IDService
pings *ping.PingService pings *ping.PingService
natmgr NATManager natmgr NATManager
maResolver *madns.Resolver maResolver *madns.Resolver
cmgr ifconnmgr.ConnManager cmgr connmgr.ConnManager
AddrsFactory AddrsFactory AddrsFactory AddrsFactory
@@ -78,6 +82,8 @@ type BasicHost struct {
lastAddrs []ma.Multiaddr lastAddrs []ma.Multiaddr
} }
var _ host.Host = (*BasicHost)(nil)
// HostOpts holds options that can be passed to NewHost in order to // HostOpts holds options that can be passed to NewHost in order to
// customize construction of the *BasicHost. // customize construction of the *BasicHost.
type HostOpts struct { type HostOpts struct {
@@ -104,17 +110,17 @@ type HostOpts struct {
// NATManager takes care of setting NAT port mappings, and discovering external addresses. // NATManager takes care of setting NAT port mappings, and discovering external addresses.
// If omitted, this will simply be disabled. // If omitted, this will simply be disabled.
NATManager func(inet.Network) NATManager NATManager func(network.Network) NATManager
// ConnManager is a libp2p connection manager // ConnManager is a libp2p connection manager
ConnManager ifconnmgr.ConnManager ConnManager connmgr.ConnManager
// EnablePing indicates whether to instantiate the ping service // EnablePing indicates whether to instantiate the ping service
EnablePing bool EnablePing bool
} }
// NewHost constructs a new *BasicHost and activates it by attaching its stream and connection handlers to the given inet.Network. // NewHost constructs a new *BasicHost and activates it by attaching its stream and connection handlers to the given inet.Network.
func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost, error) { func NewHost(ctx context.Context, net network.Network, opts *HostOpts) (*BasicHost, error) {
bgctx, cancel := context.WithCancel(ctx) bgctx, cancel := context.WithCancel(ctx)
h := &BasicHost{ h := &BasicHost{
@@ -162,7 +168,7 @@ func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost,
} }
if opts.ConnManager == nil { if opts.ConnManager == nil {
h.cmgr = &ifconnmgr.NullConnMgr{} h.cmgr = &connmgr.NullConnMgr{}
} else { } else {
h.cmgr = opts.ConnManager h.cmgr = opts.ConnManager
net.Notify(h.cmgr.Notifee()) net.Notify(h.cmgr.Notifee())
@@ -182,11 +188,11 @@ func NewHost(ctx context.Context, net inet.Network, opts *HostOpts) (*BasicHost,
// The following options can be passed: // The following options can be passed:
// * NATPortMap // * NATPortMap
// * AddrsFactory // * AddrsFactory
// * ifconnmgr.ConnManager // * connmgr.ConnManager
// * madns.Resolver // * madns.Resolver
// //
// This function is deprecated in favor of NewHost and HostOpts. // This function is deprecated in favor of NewHost and HostOpts.
func New(net inet.Network, opts ...interface{}) *BasicHost { func New(net network.Network, opts ...interface{}) *BasicHost {
hostopts := &HostOpts{} hostopts := &HostOpts{}
for _, o := range opts { for _, o := range opts {
@@ -198,7 +204,7 @@ func New(net inet.Network, opts ...interface{}) *BasicHost {
} }
case AddrsFactory: case AddrsFactory:
hostopts.AddrsFactory = AddrsFactory(o) hostopts.AddrsFactory = AddrsFactory(o)
case ifconnmgr.ConnManager: case connmgr.ConnManager:
hostopts.ConnManager = o hostopts.ConnManager = o
case *madns.Resolver: case *madns.Resolver:
hostopts.MultiaddrResolver = o hostopts.MultiaddrResolver = o
@@ -221,16 +227,16 @@ func (h *BasicHost) Start() {
} }
// newConnHandler is the remote-opened conn handler for inet.Network // newConnHandler is the remote-opened conn handler for inet.Network
func (h *BasicHost) newConnHandler(c inet.Conn) { func (h *BasicHost) newConnHandler(c network.Conn) {
// Clear protocols on connecting to new peer to avoid issues caused // Clear protocols on connecting to new peer to avoid issues caused
// by misremembering protocols between reconnects // by misremembering protocols between reconnects
h.Peerstore().SetProtocols(c.RemotePeer()) h.Peerstore().SetProtocols(c.RemotePeer())
h.ids.IdentifyConn(c) h.ids.IdentifyConn(c)
} }
// newStreamHandler is the remote-opened stream handler for inet.Network // newStreamHandler is the remote-opened stream handler for network.Network
// TODO: this feels a bit wonky // TODO: this feels a bit wonky
func (h *BasicHost) newStreamHandler(s inet.Stream) { func (h *BasicHost) newStreamHandler(s network.Stream) {
before := time.Now() before := time.Now()
if h.negtimeout > 0 { if h.negtimeout > 0 {
@@ -344,17 +350,17 @@ func (h *BasicHost) ID() peer.ID {
} }
// Peerstore returns the Host's repository of Peer Addresses and Keys. // Peerstore returns the Host's repository of Peer Addresses and Keys.
func (h *BasicHost) Peerstore() pstore.Peerstore { func (h *BasicHost) Peerstore() peerstore.Peerstore {
return h.Network().Peerstore() return h.Network().Peerstore()
} }
// Network returns the Network interface of the Host // Network returns the Network interface of the Host
func (h *BasicHost) Network() inet.Network { func (h *BasicHost) Network() network.Network {
return h.network return h.network
} }
// Mux returns the Mux multiplexing incoming streams to protocol handlers // Mux returns the Mux multiplexing incoming streams to protocol handlers
func (h *BasicHost) Mux() *msmux.MultistreamMuxer { func (h *BasicHost) Mux() protocol.Switch {
return h.mux return h.mux
} }
@@ -367,9 +373,9 @@ func (h *BasicHost) IDService() *identify.IDService {
// This is equivalent to: // This is equivalent to:
// host.Mux().SetHandler(proto, handler) // host.Mux().SetHandler(proto, handler)
// (Threadsafe) // (Threadsafe)
func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler) { func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler) {
h.Mux().AddHandler(string(pid), func(p string, rwc io.ReadWriteCloser) error { h.Mux().AddHandler(string(pid), func(p string, rwc io.ReadWriteCloser) error {
is := rwc.(inet.Stream) is := rwc.(network.Stream)
is.SetProtocol(protocol.ID(p)) is.SetProtocol(protocol.ID(p))
handler(is) handler(is)
return nil return nil
@@ -378,9 +384,9 @@ func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler
// SetStreamHandlerMatch sets the protocol handler on the Host's Mux // SetStreamHandlerMatch sets the protocol handler on the Host's Mux
// using a matching function to do protocol comparisons // using a matching function to do protocol comparisons
func (h *BasicHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool, handler inet.StreamHandler) { func (h *BasicHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool, handler network.StreamHandler) {
h.Mux().AddHandlerWithFunc(string(pid), m, func(p string, rwc io.ReadWriteCloser) error { h.Mux().AddHandlerWithFunc(string(pid), m, func(p string, rwc io.ReadWriteCloser) error {
is := rwc.(inet.Stream) is := rwc.(network.Stream)
is.SetProtocol(protocol.ID(p)) is.SetProtocol(protocol.ID(p))
handler(is) handler(is)
return nil return nil
@@ -396,7 +402,7 @@ func (h *BasicHost) RemoveStreamHandler(pid protocol.ID) {
// header with given protocol.ID. If there is no connection to p, attempts // header with given protocol.ID. If there is no connection to p, attempts
// to create one. If ProtocolID is "", writes no header. // to create one. If ProtocolID is "", writes no header.
// (Threadsafe) // (Threadsafe)
func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (inet.Stream, error) { func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error) {
pref, err := h.preferredProtocol(p, pids) pref, err := h.preferredProtocol(p, pids)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -450,7 +456,7 @@ func (h *BasicHost) preferredProtocol(p peer.ID, pids []protocol.ID) (protocol.I
return out, nil return out, nil
} }
func (h *BasicHost) newStream(ctx context.Context, p peer.ID, pid protocol.ID) (inet.Stream, error) { func (h *BasicHost) newStream(ctx context.Context, p peer.ID, pid protocol.ID) (network.Stream, error) {
s, err := h.Network().NewStream(ctx, p) s, err := h.Network().NewStream(ctx, p)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -470,11 +476,11 @@ func (h *BasicHost) newStream(ctx context.Context, p peer.ID, pid protocol.ID) (
// h.Network.Dial, and block until a connection is open, or an error is returned. // h.Network.Dial, and block until a connection is open, or an error is returned.
// Connect will absorb the addresses in pi into its internal peerstore. // Connect will absorb the addresses in pi into its internal peerstore.
// It will also resolve any /dns4, /dns6, and /dnsaddr addresses. // It will also resolve any /dns4, /dns6, and /dnsaddr addresses.
func (h *BasicHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { func (h *BasicHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
// absorb addresses into peerstore // absorb addresses into peerstore
h.Peerstore().AddAddrs(pi.ID, pi.Addrs, pstore.TempAddrTTL) h.Peerstore().AddAddrs(pi.ID, pi.Addrs, peerstore.TempAddrTTL)
if h.Network().Connectedness(pi.ID) == inet.Connected { if h.Network().Connectedness(pi.ID) == network.Connected {
return nil return nil
} }
@@ -482,12 +488,12 @@ func (h *BasicHost) Connect(ctx context.Context, pi pstore.PeerInfo) error {
if err != nil { if err != nil {
return err return err
} }
h.Peerstore().AddAddrs(pi.ID, resolved, pstore.TempAddrTTL) h.Peerstore().AddAddrs(pi.ID, resolved, peerstore.TempAddrTTL)
return h.dialPeer(ctx, pi.ID) return h.dialPeer(ctx, pi.ID)
} }
func (h *BasicHost) resolveAddrs(ctx context.Context, pi pstore.PeerInfo) ([]ma.Multiaddr, error) { func (h *BasicHost) resolveAddrs(ctx context.Context, pi peer.AddrInfo) ([]ma.Multiaddr, error) {
proto := ma.ProtocolWithCode(ma.P_P2P).Name proto := ma.ProtocolWithCode(ma.P_P2P).Name
p2paddr, err := ma.NewMultiaddr("/" + proto + "/" + pi.ID.Pretty()) p2paddr, err := ma.NewMultiaddr("/" + proto + "/" + pi.ID.Pretty())
if err != nil { if err != nil {
@@ -507,7 +513,7 @@ func (h *BasicHost) resolveAddrs(ctx context.Context, pi pstore.PeerInfo) ([]ma.
log.Infof("error resolving %s: %s", reqaddr, err) log.Infof("error resolving %s: %s", reqaddr, err)
} }
for _, res := range resaddrs { for _, res := range resaddrs {
pi, err := pstore.InfoFromP2pAddr(res) pi, err := peer.AddrInfoFromP2pAddr(res)
if err != nil { if err != nil {
log.Infof("error parsing %s: %s", res, err) log.Infof("error parsing %s: %s", res, err)
} }
@@ -549,7 +555,7 @@ func (h *BasicHost) dialPeer(ctx context.Context, p peer.ID) error {
return nil return nil
} }
func (h *BasicHost) ConnManager() ifconnmgr.ConnManager { func (h *BasicHost) ConnManager() connmgr.ConnManager {
return h.cmgr return h.cmgr
} }
@@ -724,7 +730,7 @@ func (h *BasicHost) Close() error {
} }
type streamWrapper struct { type streamWrapper struct {
inet.Stream network.Stream
rw io.ReadWriter rw io.ReadWriter
} }

View File

@@ -8,19 +8,19 @@ import (
"testing" "testing"
"time" "time"
testutil "github.com/libp2p/go-testutil" "github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-core/test"
host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net"
pstore "github.com/libp2p/go-libp2p-peerstore"
protocol "github.com/libp2p/go-libp2p-protocol"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
) )
func TestHostSimple(t *testing.T) { func TestHostSimple(t *testing.T) {
ctx := context.Background() ctx := context.Background()
h1 := New(swarmt.GenSwarm(t, ctx)) h1 := New(swarmt.GenSwarm(t, ctx))
h2 := New(swarmt.GenSwarm(t, ctx)) h2 := New(swarmt.GenSwarm(t, ctx))
@@ -33,7 +33,7 @@ func TestHostSimple(t *testing.T) {
} }
piper, pipew := io.Pipe() piper, pipew := io.Pipe()
h2.SetStreamHandler(protocol.TestingID, func(s inet.Stream) { h2.SetStreamHandler(protocol.TestingID, func(s network.Stream) {
defer s.Close() defer s.Close()
w := io.MultiWriter(s, pipew) w := io.MultiWriter(s, pipew)
io.Copy(w, s) // mirror everything io.Copy(w, s) // mirror everything
@@ -125,7 +125,7 @@ func TestHostProtoPreference(t *testing.T) {
connectedOn := make(chan protocol.ID) connectedOn := make(chan protocol.ID)
handler := func(s inet.Stream) { handler := func(s network.Stream) {
connectedOn <- s.Protocol() connectedOn <- s.Protocol()
s.Close() s.Close()
} }
@@ -140,7 +140,7 @@ func TestHostProtoPreference(t *testing.T) {
assertWait(t, connectedOn, protoOld) assertWait(t, connectedOn, protoOld)
s.Close() s.Close()
mfunc, err := host.MultistreamSemverMatcher(protoMinor) mfunc, err := helpers.MultistreamSemverMatcher(protoMinor)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -180,7 +180,7 @@ func TestHostProtoMismatch(t *testing.T) {
defer h1.Close() defer h1.Close()
defer h2.Close() defer h2.Close()
h1.SetStreamHandler("/super", func(s inet.Stream) { h1.SetStreamHandler("/super", func(s network.Stream) {
t.Error("shouldnt get here") t.Error("shouldnt get here")
s.Reset() s.Reset()
}) })
@@ -199,7 +199,7 @@ func TestHostProtoPreknowledge(t *testing.T) {
h2 := New(swarmt.GenSwarm(t, ctx)) h2 := New(swarmt.GenSwarm(t, ctx))
conn := make(chan protocol.ID) conn := make(chan protocol.ID)
handler := func(s inet.Stream) { handler := func(s network.Stream) {
conn <- s.Protocol() conn <- s.Protocol()
s.Close() s.Close()
} }
@@ -258,7 +258,7 @@ func TestNewDialOld(t *testing.T) {
defer h2.Close() defer h2.Close()
connectedOn := make(chan protocol.ID) connectedOn := make(chan protocol.ID)
h1.SetStreamHandler("/testing", func(s inet.Stream) { h1.SetStreamHandler("/testing", func(s network.Stream) {
connectedOn <- s.Protocol() connectedOn <- s.Protocol()
s.Close() s.Close()
}) })
@@ -286,7 +286,7 @@ func TestProtoDowngrade(t *testing.T) {
defer h2.Close() defer h2.Close()
connectedOn := make(chan protocol.ID) connectedOn := make(chan protocol.ID)
h1.SetStreamHandler("/testing/1.0.0", func(s inet.Stream) { h1.SetStreamHandler("/testing/1.0.0", func(s network.Stream) {
connectedOn <- s.Protocol() connectedOn <- s.Protocol()
s.Close() s.Close()
}) })
@@ -307,7 +307,7 @@ func TestProtoDowngrade(t *testing.T) {
time.Sleep(time.Millisecond * 50) // allow notifications to propogate time.Sleep(time.Millisecond * 50) // allow notifications to propogate
h1.RemoveStreamHandler("/testing/1.0.0") h1.RemoveStreamHandler("/testing/1.0.0")
h1.SetStreamHandler("/testing", func(s inet.Stream) { h1.SetStreamHandler("/testing", func(s network.Stream) {
connectedOn <- s.Protocol() connectedOn <- s.Protocol()
s.Close() s.Close()
}) })
@@ -339,11 +339,11 @@ func TestProtoDowngrade(t *testing.T) {
func TestAddrResolution(t *testing.T) { func TestAddrResolution(t *testing.T) {
ctx := context.Background() ctx := context.Background()
p1, err := testutil.RandPeerID() p1, err := test.RandPeerID()
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
p2, err := testutil.RandPeerID() p2, err := test.RandPeerID()
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
@@ -363,7 +363,7 @@ func TestAddrResolution(t *testing.T) {
h := New(swarmt.GenSwarm(t, ctx), resolver) h := New(swarmt.GenSwarm(t, ctx), resolver)
defer h.Close() defer h.Close()
pi, err := pstore.InfoFromP2pAddr(p2paddr1) pi, err := peer.AddrInfoFromP2pAddr(p2paddr1)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }

View File

@@ -7,8 +7,8 @@ import (
goprocess "github.com/jbenet/goprocess" goprocess "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
"github.com/libp2p/go-libp2p-core/network"
inat "github.com/libp2p/go-libp2p-nat" inat "github.com/libp2p/go-libp2p-nat"
inet "github.com/libp2p/go-libp2p-net"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -26,7 +26,7 @@ type NATManager interface {
} }
// Create a NAT manager. // Create a NAT manager.
func NewNATManager(net inet.Network) NATManager { func NewNATManager(net network.Network) NATManager {
return newNatManager(net) return newNatManager(net)
} }
@@ -37,7 +37,7 @@ func NewNATManager(net inet.Network) NATManager {
// as the network signals Listen() or ListenClose(). // as the network signals Listen() or ListenClose().
// * closing the natManager closes the nat and its mappings. // * closing the natManager closes the nat and its mappings.
type natManager struct { type natManager struct {
net inet.Network net network.Network
natmu sync.RWMutex natmu sync.RWMutex
nat *inat.NAT nat *inat.NAT
@@ -48,7 +48,7 @@ type natManager struct {
proc goprocess.Process // natManager has a process + children. can be closed. proc goprocess.Process // natManager has a process + children. can be closed.
} }
func newNatManager(net inet.Network) *natManager { func newNatManager(net network.Network) *natManager {
nmgr := &natManager{ nmgr := &natManager{
net: net, net: net,
ready: make(chan struct{}), ready: make(chan struct{}),
@@ -229,15 +229,15 @@ func (nn *nmgrNetNotifiee) natManager() *natManager {
return (*natManager)(nn) return (*natManager)(nn)
} }
func (nn *nmgrNetNotifiee) Listen(n inet.Network, addr ma.Multiaddr) { func (nn *nmgrNetNotifiee) Listen(n network.Network, addr ma.Multiaddr) {
nn.natManager().sync() nn.natManager().sync()
} }
func (nn *nmgrNetNotifiee) ListenClose(n inet.Network, addr ma.Multiaddr) { func (nn *nmgrNetNotifiee) ListenClose(n network.Network, addr ma.Multiaddr) {
nn.natManager().sync() nn.natManager().sync()
} }
func (nn *nmgrNetNotifiee) Connected(inet.Network, inet.Conn) {} func (nn *nmgrNetNotifiee) Connected(network.Network, network.Conn) {}
func (nn *nmgrNetNotifiee) Disconnected(inet.Network, inet.Conn) {} func (nn *nmgrNetNotifiee) Disconnected(network.Network, network.Conn) {}
func (nn *nmgrNetNotifiee) OpenedStream(inet.Network, inet.Stream) {} func (nn *nmgrNetNotifiee) OpenedStream(network.Network, network.Stream) {}
func (nn *nmgrNetNotifiee) ClosedStream(inet.Network, inet.Stream) {} func (nn *nmgrNetNotifiee) ClosedStream(network.Network, network.Stream) {}

View File

@@ -7,15 +7,15 @@ import (
"sync" "sync"
"time" "time"
basic "github.com/libp2p/go-libp2p/p2p/host/basic" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/routing"
autonat "github.com/libp2p/go-libp2p-autonat" autonat "github.com/libp2p/go-libp2p-autonat"
_ "github.com/libp2p/go-libp2p-circuit" _ "github.com/libp2p/go-libp2p-circuit"
discovery "github.com/libp2p/go-libp2p-discovery" discovery "github.com/libp2p/go-libp2p-discovery"
inet "github.com/libp2p/go-libp2p-net" basic "github.com/libp2p/go-libp2p/p2p/host/basic"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
routing "github.com/libp2p/go-libp2p-routing"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net" manet "github.com/multiformats/go-multiaddr-net"
) )
@@ -188,7 +188,7 @@ func (ar *AutoRelay) usingRelay(p peer.ID) bool {
// addRelay adds the given relay to our set of relays. // addRelay adds the given relay to our set of relays.
// returns true when we add a new relay // returns true when we add a new relay
func (ar *AutoRelay) tryRelay(ctx context.Context, pi pstore.PeerInfo) bool { func (ar *AutoRelay) tryRelay(ctx context.Context, pi peer.AddrInfo) bool {
if ar.usingRelay(pi.ID) { if ar.usingRelay(pi.ID) {
return false return false
} }
@@ -201,7 +201,7 @@ func (ar *AutoRelay) tryRelay(ctx context.Context, pi pstore.PeerInfo) bool {
defer ar.mx.Unlock() defer ar.mx.Unlock()
// make sure we're still connected. // make sure we're still connected.
if ar.host.Network().Connectedness(pi.ID) != inet.Connected { if ar.host.Network().Connectedness(pi.ID) != network.Connected {
return false return false
} }
ar.relays[pi.ID] = struct{}{} ar.relays[pi.ID] = struct{}{}
@@ -209,7 +209,7 @@ func (ar *AutoRelay) tryRelay(ctx context.Context, pi pstore.PeerInfo) bool {
return true return true
} }
func (ar *AutoRelay) connect(ctx context.Context, pi pstore.PeerInfo) bool { func (ar *AutoRelay) connect(ctx context.Context, pi peer.AddrInfo) bool {
ctx, cancel := context.WithTimeout(ctx, 60*time.Second) ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel() defer cancel()
@@ -233,13 +233,13 @@ func (ar *AutoRelay) connect(ctx context.Context, pi pstore.PeerInfo) bool {
return true return true
} }
func (ar *AutoRelay) discoverRelays(ctx context.Context) ([]pstore.PeerInfo, error) { func (ar *AutoRelay) discoverRelays(ctx context.Context) ([]peer.AddrInfo, error) {
ctx, cancel := context.WithTimeout(ctx, 30*time.Second) ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel() defer cancel()
return discovery.FindPeers(ctx, ar.discover, RelayRendezvous, discovery.Limit(1000)) return discovery.FindPeers(ctx, ar.discover, RelayRendezvous, discovery.Limit(1000))
} }
func (ar *AutoRelay) selectRelays(ctx context.Context, pis []pstore.PeerInfo) []pstore.PeerInfo { func (ar *AutoRelay) selectRelays(ctx context.Context, pis []peer.AddrInfo) []peer.AddrInfo {
// TODO better relay selection strategy; this just selects random relays // TODO better relay selection strategy; this just selects random relays
// but we should probably use ping latency as the selection metric // but we should probably use ping latency as the selection metric
@@ -296,7 +296,7 @@ func (ar *AutoRelay) relayAddrs(addrs []ma.Multiaddr) []ma.Multiaddr {
return raddrs return raddrs
} }
func shuffleRelays(pis []pstore.PeerInfo) { func shuffleRelays(pis []peer.AddrInfo) {
for i := range pis { for i := range pis {
j := rand.Intn(i + 1) j := rand.Intn(i + 1)
pis[i], pis[j] = pis[j], pis[i] pis[i], pis[j] = pis[j], pis[i]
@@ -304,17 +304,17 @@ func shuffleRelays(pis []pstore.PeerInfo) {
} }
// Notifee // Notifee
func (ar *AutoRelay) Listen(inet.Network, ma.Multiaddr) {} func (ar *AutoRelay) Listen(network.Network, ma.Multiaddr) {}
func (ar *AutoRelay) ListenClose(inet.Network, ma.Multiaddr) {} func (ar *AutoRelay) ListenClose(network.Network, ma.Multiaddr) {}
func (ar *AutoRelay) Connected(inet.Network, inet.Conn) {} func (ar *AutoRelay) Connected(network.Network, network.Conn) {}
func (ar *AutoRelay) Disconnected(net inet.Network, c inet.Conn) { func (ar *AutoRelay) Disconnected(net network.Network, c network.Conn) {
p := c.RemotePeer() p := c.RemotePeer()
ar.mx.Lock() ar.mx.Lock()
defer ar.mx.Unlock() defer ar.mx.Unlock()
if ar.host.Network().Connectedness(p) == inet.Connected { if ar.host.Network().Connectedness(p) == network.Connected {
// We have a second connection. // We have a second connection.
return return
} }
@@ -328,5 +328,5 @@ func (ar *AutoRelay) Disconnected(net inet.Network, c inet.Conn) {
} }
} }
func (ar *AutoRelay) OpenedStream(inet.Network, inet.Stream) {} func (ar *AutoRelay) OpenedStream(network.Network, network.Stream) {}
func (ar *AutoRelay) ClosedStream(inet.Network, inet.Stream) {} func (ar *AutoRelay) ClosedStream(network.Network, network.Stream) {}

View File

@@ -16,11 +16,10 @@ import (
autonat "github.com/libp2p/go-libp2p-autonat" autonat "github.com/libp2p/go-libp2p-autonat"
autonatpb "github.com/libp2p/go-libp2p-autonat/pb" autonatpb "github.com/libp2p/go-libp2p-autonat/pb"
circuit "github.com/libp2p/go-libp2p-circuit" circuit "github.com/libp2p/go-libp2p-circuit"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-peerstore" "github.com/libp2p/go-libp2p-core/routing"
routing "github.com/libp2p/go-libp2p-routing"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net" manet "github.com/multiformats/go-multiaddr-net"
) )
@@ -36,8 +35,8 @@ func init() {
// mock routing // mock routing
type mockRoutingTable struct { type mockRoutingTable struct {
mx sync.Mutex mx sync.Mutex
providers map[string]map[peer.ID]pstore.PeerInfo providers map[string]map[peer.ID]peer.AddrInfo
peers map[peer.ID]pstore.PeerInfo peers map[peer.ID]peer.AddrInfo
} }
type mockRouting struct { type mockRouting struct {
@@ -46,19 +45,19 @@ type mockRouting struct {
} }
func newMockRoutingTable() *mockRoutingTable { func newMockRoutingTable() *mockRoutingTable {
return &mockRoutingTable{providers: make(map[string]map[peer.ID]pstore.PeerInfo)} return &mockRoutingTable{providers: make(map[string]map[peer.ID]peer.AddrInfo)}
} }
func newMockRouting(h host.Host, tab *mockRoutingTable) *mockRouting { func newMockRouting(h host.Host, tab *mockRoutingTable) *mockRouting {
return &mockRouting{h: h, tab: tab} return &mockRouting{h: h, tab: tab}
} }
func (m *mockRouting) FindPeer(ctx context.Context, p peer.ID) (pstore.PeerInfo, error) { func (m *mockRouting) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) {
m.tab.mx.Lock() m.tab.mx.Lock()
defer m.tab.mx.Unlock() defer m.tab.mx.Unlock()
pi, ok := m.tab.peers[p] pi, ok := m.tab.peers[p]
if !ok { if !ok {
return pstore.PeerInfo{}, routing.ErrNotFound return peer.AddrInfo{}, routing.ErrNotFound
} }
return pi, nil return pi, nil
} }
@@ -69,22 +68,22 @@ func (m *mockRouting) Provide(ctx context.Context, cid cid.Cid, bcast bool) erro
pmap, ok := m.tab.providers[cid.String()] pmap, ok := m.tab.providers[cid.String()]
if !ok { if !ok {
pmap = make(map[peer.ID]pstore.PeerInfo) pmap = make(map[peer.ID]peer.AddrInfo)
m.tab.providers[cid.String()] = pmap m.tab.providers[cid.String()] = pmap
} }
pi := pstore.PeerInfo{ID: m.h.ID(), Addrs: m.h.Addrs()} pi := peer.AddrInfo{ID: m.h.ID(), Addrs: m.h.Addrs()}
pmap[m.h.ID()] = pi pmap[m.h.ID()] = pi
if m.tab.peers == nil { if m.tab.peers == nil {
m.tab.peers = make(map[peer.ID]pstore.PeerInfo) m.tab.peers = make(map[peer.ID]peer.AddrInfo)
} }
m.tab.peers[m.h.ID()] = pi m.tab.peers[m.h.ID()] = pi
return nil return nil
} }
func (m *mockRouting) FindProvidersAsync(ctx context.Context, cid cid.Cid, limit int) <-chan pstore.PeerInfo { func (m *mockRouting) FindProvidersAsync(ctx context.Context, cid cid.Cid, limit int) <-chan peer.AddrInfo {
ch := make(chan pstore.PeerInfo) ch := make(chan peer.AddrInfo)
go func() { go func() {
defer close(ch) defer close(ch)
m.tab.mx.Lock() m.tab.mx.Lock()
@@ -117,7 +116,7 @@ func makeAutoNATServicePrivate(ctx context.Context, t *testing.T) host.Host {
return h return h
} }
func sayAutoNATPrivate(s inet.Stream) { func sayAutoNATPrivate(s network.Stream) {
defer s.Close() defer s.Close()
w := ggio.NewDelimitedWriter(s) w := ggio.NewDelimitedWriter(s)
res := autonatpb.Message{ res := autonatpb.Message{
@@ -136,7 +135,7 @@ func newDialResponseError(status autonatpb.Message_ResponseStatus, text string)
// connector // connector
func connect(t *testing.T, a, b host.Host) { func connect(t *testing.T, a, b host.Host) {
pinfo := pstore.PeerInfo{ID: a.ID(), Addrs: a.Addrs()} pinfo := peer.AddrInfo{ID: a.ID(), Addrs: a.Addrs()}
err := b.Connect(context.Background(), pinfo) err := b.Connect(context.Background(), pinfo)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -214,7 +213,7 @@ func TestAutoRelay(t *testing.T) {
} }
} }
err = h4.Connect(ctx, pstore.PeerInfo{ID: h3.ID(), Addrs: raddrs}) err = h4.Connect(ctx, peer.AddrInfo{ID: h3.ID(), Addrs: raddrs})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -4,7 +4,8 @@ import (
"context" "context"
"time" "time"
discovery "github.com/libp2p/go-libp2p-discovery" "github.com/libp2p/go-libp2p-discovery"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )

View File

@@ -5,18 +5,18 @@ import (
"fmt" "fmt"
"time" "time"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/protocol"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
circuit "github.com/libp2p/go-libp2p-circuit" circuit "github.com/libp2p/go-libp2p-circuit"
ifconnmgr "github.com/libp2p/go-libp2p-interface-connmgr"
lgbl "github.com/libp2p/go-libp2p-loggables" lgbl "github.com/libp2p/go-libp2p-loggables"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
protocol "github.com/libp2p/go-libp2p-protocol"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
msmux "github.com/multiformats/go-multistream"
) )
var log = logging.Logger("routedhost") var log = logging.Logger("routedhost")
@@ -34,7 +34,7 @@ type RoutedHost struct {
} }
type Routing interface { type Routing interface {
FindPeer(context.Context, peer.ID) (pstore.PeerInfo, error) FindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
} }
func Wrap(h host.Host, r Routing) *RoutedHost { func Wrap(h host.Host, r Routing) *RoutedHost {
@@ -46,15 +46,15 @@ func Wrap(h host.Host, r Routing) *RoutedHost {
// //
// RoutedHost's Connect differs in that if the host has no addresses for a // RoutedHost's Connect differs in that if the host has no addresses for a
// given peer, it will use its routing system to try to find some. // given peer, it will use its routing system to try to find some.
func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { func (rh *RoutedHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
// first, check if we're already connected. // first, check if we're already connected.
if rh.Network().Connectedness(pi.ID) == inet.Connected { if rh.Network().Connectedness(pi.ID) == network.Connected {
return nil return nil
} }
// if we were given some addresses, keep + use them. // if we were given some addresses, keep + use them.
if len(pi.Addrs) > 0 { if len(pi.Addrs) > 0 {
rh.Peerstore().AddAddrs(pi.ID, pi.Addrs, pstore.TempAddrTTL) rh.Peerstore().AddAddrs(pi.ID, pi.Addrs, peerstore.TempAddrTTL)
} }
// Check if we have some addresses in our recent memory. // Check if we have some addresses in our recent memory.
@@ -102,7 +102,7 @@ func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error {
continue continue
} }
rh.Peerstore().AddAddrs(relayID, relayAddrs, pstore.TempAddrTTL) rh.Peerstore().AddAddrs(relayID, relayAddrs, peerstore.TempAddrTTL)
} }
// if we're here, we got some addrs. let's use our wrapped host to connect. // if we're here, we got some addrs. let's use our wrapped host to connect.
@@ -137,7 +137,7 @@ func (rh *RoutedHost) ID() peer.ID {
return rh.host.ID() return rh.host.ID()
} }
func (rh *RoutedHost) Peerstore() pstore.Peerstore { func (rh *RoutedHost) Peerstore() peerstore.Peerstore {
return rh.host.Peerstore() return rh.host.Peerstore()
} }
@@ -145,19 +145,19 @@ func (rh *RoutedHost) Addrs() []ma.Multiaddr {
return rh.host.Addrs() return rh.host.Addrs()
} }
func (rh *RoutedHost) Network() inet.Network { func (rh *RoutedHost) Network() network.Network {
return rh.host.Network() return rh.host.Network()
} }
func (rh *RoutedHost) Mux() *msmux.MultistreamMuxer { func (rh *RoutedHost) Mux() protocol.Switch {
return rh.host.Mux() return rh.host.Mux()
} }
func (rh *RoutedHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler) { func (rh *RoutedHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler) {
rh.host.SetStreamHandler(pid, handler) rh.host.SetStreamHandler(pid, handler)
} }
func (rh *RoutedHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool, handler inet.StreamHandler) { func (rh *RoutedHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool, handler network.StreamHandler) {
rh.host.SetStreamHandlerMatch(pid, m, handler) rh.host.SetStreamHandlerMatch(pid, m, handler)
} }
@@ -165,13 +165,13 @@ func (rh *RoutedHost) RemoveStreamHandler(pid protocol.ID) {
rh.host.RemoveStreamHandler(pid) rh.host.RemoveStreamHandler(pid)
} }
func (rh *RoutedHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (inet.Stream, error) { func (rh *RoutedHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error) {
// Ensure we have a connection, with peer addresses resolved by the routing system (#207) // Ensure we have a connection, with peer addresses resolved by the routing system (#207)
// It is not sufficient to let the underlying host connect, it will most likely not have // It is not sufficient to let the underlying host connect, it will most likely not have
// any addresses for the peer without any prior connections. // any addresses for the peer without any prior connections.
// If the caller wants to prevent the host from dialing, it should use the NoDial option. // If the caller wants to prevent the host from dialing, it should use the NoDial option.
if nodial, _ := inet.GetNoDial(ctx); !nodial { if nodial, _ := network.GetNoDial(ctx); !nodial {
err := rh.Connect(ctx, pstore.PeerInfo{ID: p}) err := rh.Connect(ctx, peer.AddrInfo{ID: p})
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -183,7 +183,7 @@ func (rh *RoutedHost) Close() error {
// no need to close IpfsRouting. we dont own it. // no need to close IpfsRouting. we dont own it.
return rh.host.Close() return rh.host.Close()
} }
func (rh *RoutedHost) ConnManager() ifconnmgr.ConnManager { func (rh *RoutedHost) ConnManager() connmgr.ConnManager {
return rh.host.ConnManager() return rh.host.ConnManager()
} }

View File

@@ -1,43 +1,43 @@
// Package mocknet provides a mock net.Network to test with. // Package mocknet provides a mock net.Network to test with.
// //
// - a Mocknet has many inet.Networks // - a Mocknet has many network.Networks
// - a Mocknet has many Links // - a Mocknet has many Links
// - a Link joins two inet.Networks // - a Link joins two network.Networks
// - inet.Conns and inet.Streams are created by inet.Networks // - network.Conns and network.Streams are created by network.Networks
package mocknet package mocknet
import ( import (
"io" "io"
"time" "time"
host "github.com/libp2p/go-libp2p-host" ic "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
ic "github.com/libp2p/go-libp2p-crypto"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
type Mocknet interface { type Mocknet interface {
// GenPeer generates a peer and its inet.Network in the Mocknet // GenPeer generates a peer and its network.Network in the Mocknet
GenPeer() (host.Host, error) GenPeer() (host.Host, error)
// AddPeer adds an existing peer. we need both a privkey and addr. // AddPeer adds an existing peer. we need both a privkey and addr.
// ID is derived from PrivKey // ID is derived from PrivKey
AddPeer(ic.PrivKey, ma.Multiaddr) (host.Host, error) AddPeer(ic.PrivKey, ma.Multiaddr) (host.Host, error)
AddPeerWithPeerstore(peer.ID, pstore.Peerstore) (host.Host, error) AddPeerWithPeerstore(peer.ID, peerstore.Peerstore) (host.Host, error)
// retrieve things (with randomized iteration order) // retrieve things (with randomized iteration order)
Peers() []peer.ID Peers() []peer.ID
Net(peer.ID) inet.Network Net(peer.ID) network.Network
Nets() []inet.Network Nets() []network.Network
Host(peer.ID) host.Host Host(peer.ID) host.Host
Hosts() []host.Host Hosts() []host.Host
Links() LinkMap Links() LinkMap
LinksBetweenPeers(a, b peer.ID) []Link LinksBetweenPeers(a, b peer.ID) []Link
LinksBetweenNets(a, b inet.Network) []Link LinksBetweenNets(a, b network.Network) []Link
// Links are the **ability to connect**. // Links are the **ability to connect**.
// think of Links as the physical medium. // think of Links as the physical medium.
@@ -45,10 +45,10 @@ type Mocknet interface {
// (this makes it possible to test dial failures, and // (this makes it possible to test dial failures, and
// things like relaying traffic) // things like relaying traffic)
LinkPeers(peer.ID, peer.ID) (Link, error) LinkPeers(peer.ID, peer.ID) (Link, error)
LinkNets(inet.Network, inet.Network) (Link, error) LinkNets(network.Network, network.Network) (Link, error)
Unlink(Link) error Unlink(Link) error
UnlinkPeers(peer.ID, peer.ID) error UnlinkPeers(peer.ID, peer.ID) error
UnlinkNets(inet.Network, inet.Network) error UnlinkNets(network.Network, network.Network) error
// LinkDefaults are the default options that govern links // LinkDefaults are the default options that govern links
// if they do not have thier own option set. // if they do not have thier own option set.
@@ -57,10 +57,10 @@ type Mocknet interface {
// Connections are the usual. Connecting means Dialing. // Connections are the usual. Connecting means Dialing.
// **to succeed, peers must be linked beforehand** // **to succeed, peers must be linked beforehand**
ConnectPeers(peer.ID, peer.ID) (inet.Conn, error) ConnectPeers(peer.ID, peer.ID) (network.Conn, error)
ConnectNets(inet.Network, inet.Network) (inet.Conn, error) ConnectNets(network.Network, network.Network) (network.Conn, error)
DisconnectPeers(peer.ID, peer.ID) error DisconnectPeers(peer.ID, peer.ID) error
DisconnectNets(inet.Network, inet.Network) error DisconnectNets(network.Network, network.Network) error
LinkAll() error LinkAll() error
ConnectAllButSelf() error ConnectAllButSelf() error
} }
@@ -79,7 +79,7 @@ type LinkOptions struct {
// connect. This allows constructing topologies where specific // connect. This allows constructing topologies where specific
// nodes cannot talk to each other directly. :) // nodes cannot talk to each other directly. :)
type Link interface { type Link interface {
Networks() []inet.Network Networks() []network.Network
Peers() []peer.ID Peers() []peer.ID
SetOptions(LinkOptions) SetOptions(LinkOptions)
@@ -96,7 +96,7 @@ type LinkMap map[string]map[string]map[Link]struct{}
type Printer interface { type Printer interface {
// MocknetLinks shows the entire Mocknet's link table :) // MocknetLinks shows the entire Mocknet's link table :)
MocknetLinks(mn Mocknet) MocknetLinks(mn Mocknet)
NetworkConns(ni inet.Network) NetworkConns(ni network.Network)
} }
// PrinterTo returns a Printer ready to write to w. // PrinterTo returns a Printer ready to write to w.

View File

@@ -5,9 +5,9 @@ import (
"sync" "sync"
process "github.com/jbenet/goprocess" process "github.com/jbenet/goprocess"
ic "github.com/libp2p/go-libp2p-crypto" ic "github.com/libp2p/go-libp2p-core/crypto"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
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"
) )
@@ -29,16 +29,16 @@ type conn struct {
rconn *conn // counterpart rconn *conn // counterpart
streams list.List streams list.List
proc process.Process proc process.Process
stat inet.Stat stat network.Stat
sync.RWMutex sync.RWMutex
} }
func newConn(ln, rn *peernet, l *link, dir inet.Direction) *conn { func newConn(ln, rn *peernet, l *link, dir network.Direction) *conn {
c := &conn{net: ln, link: l} c := &conn{net: ln, link: l}
c.local = ln.peer c.local = ln.peer
c.remote = rn.peer c.remote = rn.peer
c.stat = inet.Stat{Direction: dir} c.stat = network.Stat{Direction: dir}
c.localAddr = ln.ps.Addrs(ln.peer)[0] c.localAddr = ln.ps.Addrs(ln.peer)[0]
c.remoteAddr = rn.ps.Addrs(rn.peer)[0] c.remoteAddr = rn.ps.Addrs(rn.peer)[0]
@@ -59,7 +59,7 @@ func (c *conn) teardown() error {
s.Reset() s.Reset()
} }
c.net.removeConn(c) c.net.removeConn(c)
c.net.notifyAll(func(n inet.Notifiee) { c.net.notifyAll(func(n network.Notifiee) {
n.Disconnected(c.net, c) n.Disconnected(c.net, c)
}) })
return nil return nil
@@ -83,11 +83,11 @@ func (c *conn) removeStream(s *stream) {
} }
} }
func (c *conn) allStreams() []inet.Stream { func (c *conn) allStreams() []network.Stream {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
strs := make([]inet.Stream, 0, c.streams.Len()) strs := make([]network.Stream, 0, c.streams.Len())
for e := c.streams.Front(); e != nil; e = e.Next() { for e := c.streams.Front(); e != nil; e = e.Next() {
s := e.Value.(*stream) s := e.Value.(*stream)
strs = append(strs, s) strs = append(strs, s)
@@ -98,7 +98,7 @@ func (c *conn) allStreams() []inet.Stream {
func (c *conn) remoteOpenedStream(s *stream) { func (c *conn) remoteOpenedStream(s *stream) {
c.addStream(s) c.addStream(s)
c.net.handleNewStream(s) c.net.handleNewStream(s)
c.net.notifyAll(func(n inet.Notifiee) { c.net.notifyAll(func(n network.Notifiee) {
n.OpenedStream(c.net, s) n.OpenedStream(c.net, s)
}) })
} }
@@ -106,21 +106,21 @@ func (c *conn) remoteOpenedStream(s *stream) {
func (c *conn) openStream() *stream { func (c *conn) openStream() *stream {
sl, sr := c.link.newStreamPair() sl, sr := c.link.newStreamPair()
c.addStream(sl) c.addStream(sl)
c.net.notifyAll(func(n inet.Notifiee) { c.net.notifyAll(func(n network.Notifiee) {
n.OpenedStream(c.net, sl) n.OpenedStream(c.net, sl)
}) })
c.rconn.remoteOpenedStream(sr) c.rconn.remoteOpenedStream(sr)
return sl return sl
} }
func (c *conn) NewStream() (inet.Stream, error) { func (c *conn) NewStream() (network.Stream, error) {
log.Debugf("Conn.NewStreamWithProtocol: %s --> %s", c.local, c.remote) log.Debugf("Conn.NewStreamWithProtocol: %s --> %s", c.local, c.remote)
s := c.openStream() s := c.openStream()
return s, nil return s, nil
} }
func (c *conn) GetStreams() []inet.Stream { func (c *conn) GetStreams() []network.Stream {
return c.allStreams() return c.allStreams()
} }
@@ -155,6 +155,6 @@ func (c *conn) RemotePublicKey() ic.PubKey {
} }
// Stat returns metadata about the connection // Stat returns metadata about the connection
func (c *conn) Stat() inet.Stat { func (c *conn) Stat() network.Stat {
return c.stat return c.stat
} }

View File

@@ -6,12 +6,12 @@ import (
"sync" "sync"
"time" "time"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
) )
// link implements mocknet.Link // link implements mocknet.Link
// and, for simplicity, inet.Conn // and, for simplicity, network.Conn
type link struct { type link struct {
mock *mocknet mock *mocknet
nets []*peernet nets []*peernet
@@ -33,8 +33,8 @@ func (l *link) newConnPair(dialer *peernet) (*conn, *conn) {
l.RLock() l.RLock()
defer l.RUnlock() defer l.RUnlock()
c1 := newConn(l.nets[0], l.nets[1], l, inet.DirOutbound) c1 := newConn(l.nets[0], l.nets[1], l, network.DirOutbound)
c2 := newConn(l.nets[1], l.nets[0], l, inet.DirInbound) c2 := newConn(l.nets[1], l.nets[0], l, network.DirInbound)
c1.rconn = c2 c1.rconn = c2
c2.rconn = c1 c2.rconn = c1
@@ -48,16 +48,16 @@ func (l *link) newStreamPair() (*stream, *stream) {
ra, wb := io.Pipe() ra, wb := io.Pipe()
rb, wa := io.Pipe() rb, wa := io.Pipe()
sa := NewStream(wa, ra, inet.DirOutbound) sa := NewStream(wa, ra, network.DirOutbound)
sb := NewStream(wb, rb, inet.DirInbound) sb := NewStream(wb, rb, network.DirInbound)
return sa, sb return sa, sb
} }
func (l *link) Networks() []inet.Network { func (l *link) Networks() []network.Network {
l.RLock() l.RLock()
defer l.RUnlock() defer l.RUnlock()
cp := make([]inet.Network, len(l.nets)) cp := make([]network.Network, len(l.nets))
for i, n := range l.nets { for i, n := range l.nets {
cp[i] = n cp[i] = n
} }

View File

@@ -7,16 +7,18 @@ import (
"sort" "sort"
"sync" "sync"
host "github.com/libp2p/go-libp2p-host" ic "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/jbenet/goprocess" "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
ic "github.com/libp2p/go-libp2p-crypto"
inet "github.com/libp2p/go-libp2p-net"
p2putil "github.com/libp2p/go-libp2p-netutil" p2putil "github.com/libp2p/go-libp2p-netutil"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem" pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -88,14 +90,14 @@ func (mn *mocknet) AddPeer(k ic.PrivKey, a ma.Multiaddr) (host.Host, error) {
} }
ps := pstoremem.NewPeerstore() ps := pstoremem.NewPeerstore()
ps.AddAddr(p, a, pstore.PermanentAddrTTL) ps.AddAddr(p, a, peerstore.PermanentAddrTTL)
ps.AddPrivKey(p, k) ps.AddPrivKey(p, k)
ps.AddPubKey(p, k.GetPublic()) ps.AddPubKey(p, k.GetPublic())
return mn.AddPeerWithPeerstore(p, ps) return mn.AddPeerWithPeerstore(p, ps)
} }
func (mn *mocknet) AddPeerWithPeerstore(p peer.ID, ps pstore.Peerstore) (host.Host, error) { func (mn *mocknet) AddPeerWithPeerstore(p peer.ID, ps peerstore.Peerstore) (host.Host, error) {
n, err := newPeernet(mn.ctx, mn, p, ps) n, err := newPeernet(mn.ctx, mn, p, ps)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -138,7 +140,7 @@ func (mn *mocknet) Host(pid peer.ID) host.Host {
return host return host
} }
func (mn *mocknet) Net(pid peer.ID) inet.Network { func (mn *mocknet) Net(pid peer.ID) network.Network {
mn.Lock() mn.Lock()
n := mn.nets[pid] n := mn.nets[pid]
mn.Unlock() mn.Unlock()
@@ -158,11 +160,11 @@ func (mn *mocknet) Hosts() []host.Host {
return cp return cp
} }
func (mn *mocknet) Nets() []inet.Network { func (mn *mocknet) Nets() []network.Network {
mn.Lock() mn.Lock()
defer mn.Unlock() defer mn.Unlock()
cp := make([]inet.Network, 0, len(mn.nets)) cp := make([]network.Network, 0, len(mn.nets))
for _, n := range mn.nets { for _, n := range mn.nets {
cp = append(cp, n) cp = append(cp, n)
} }
@@ -220,7 +222,7 @@ func (mn *mocknet) LinkPeers(p1, p2 peer.ID) (Link, error) {
return mn.LinkNets(n1, n2) return mn.LinkNets(n1, n2)
} }
func (mn *mocknet) validate(n inet.Network) (*peernet, error) { func (mn *mocknet) validate(n network.Network) (*peernet, error) {
// WARNING: assumes locks acquired // WARNING: assumes locks acquired
nr, ok := n.(*peernet) nr, ok := n.(*peernet)
@@ -235,7 +237,7 @@ func (mn *mocknet) validate(n inet.Network) (*peernet, error) {
return nr, nil return nr, nil
} }
func (mn *mocknet) LinkNets(n1, n2 inet.Network) (Link, error) { func (mn *mocknet) LinkNets(n1, n2 network.Network) (Link, error) {
mn.Lock() mn.Lock()
n1r, err1 := mn.validate(n1) n1r, err1 := mn.validate(n1)
n2r, err2 := mn.validate(n2) n2r, err2 := mn.validate(n2)
@@ -280,7 +282,7 @@ func (mn *mocknet) UnlinkPeers(p1, p2 peer.ID) error {
return nil return nil
} }
func (mn *mocknet) UnlinkNets(n1, n2 inet.Network) error { func (mn *mocknet) UnlinkNets(n1, n2 network.Network) error {
return mn.UnlinkPeers(n1.LocalPeer(), n2.LocalPeer()) return mn.UnlinkPeers(n1.LocalPeer(), n2.LocalPeer())
} }
@@ -337,11 +339,11 @@ func (mn *mocknet) ConnectAllButSelf() error {
return nil return nil
} }
func (mn *mocknet) ConnectPeers(a, b peer.ID) (inet.Conn, error) { func (mn *mocknet) ConnectPeers(a, b peer.ID) (network.Conn, error) {
return mn.Net(a).DialPeer(mn.ctx, b) return mn.Net(a).DialPeer(mn.ctx, b)
} }
func (mn *mocknet) ConnectNets(a, b inet.Network) (inet.Conn, error) { func (mn *mocknet) ConnectNets(a, b network.Network) (network.Conn, error) {
return a.DialPeer(mn.ctx, b.LocalPeer()) return a.DialPeer(mn.ctx, b.LocalPeer())
} }
@@ -349,7 +351,7 @@ func (mn *mocknet) DisconnectPeers(p1, p2 peer.ID) error {
return mn.Net(p1).ClosePeer(p2) return mn.Net(p1).ClosePeer(p2)
} }
func (mn *mocknet) DisconnectNets(n1, n2 inet.Network) error { func (mn *mocknet) DisconnectNets(n1, n2 network.Network) error {
return n1.ClosePeer(n2.LocalPeer()) return n1.ClosePeer(n2.LocalPeer())
} }
@@ -365,7 +367,7 @@ func (mn *mocknet) LinksBetweenPeers(p1, p2 peer.ID) []Link {
return cp return cp
} }
func (mn *mocknet) LinksBetweenNets(n1, n2 inet.Network) []Link { func (mn *mocknet) LinksBetweenNets(n1, n2 network.Network) []Link {
return mn.LinksBetweenPeers(n1.LocalPeer(), n2.LocalPeer()) return mn.LinksBetweenPeers(n1.LocalPeer(), n2.LocalPeer())
} }
@@ -382,7 +384,7 @@ func (mn *mocknet) LinkDefaults() LinkOptions {
} }
// netSlice for sorting by peer // netSlice for sorting by peer
type netSlice []inet.Network type netSlice []network.Network
func (es netSlice) Len() int { return len(es) } func (es netSlice) Len() int { return len(es) }
func (es netSlice) Swap(i, j int) { es[i], es[j] = es[j], es[i] } func (es netSlice) Swap(i, j int) { es[i], es[j] = es[j], es[i] }

View File

@@ -5,8 +5,9 @@ import (
"testing" "testing"
"time" "time"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/helpers"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -37,7 +38,7 @@ func TestNotifications(t *testing.T) {
// test everyone got the correct connection opened calls // test everyone got the correct connection opened calls
for i, s := range nets { for i, s := range nets {
n := notifiees[i] n := notifiees[i]
notifs := make(map[peer.ID][]inet.Conn) notifs := make(map[peer.ID][]network.Conn)
for j, s2 := range nets { for j, s2 := range nets {
if i == j { if i == j {
continue continue
@@ -77,7 +78,7 @@ func TestNotifications(t *testing.T) {
} }
} }
complement := func(c inet.Conn) (inet.Network, *netNotifiee, *conn) { complement := func(c network.Conn) (network.Network, *netNotifiee, *conn) {
for i, s := range nets { for i, s := range nets {
for _, c2 := range s.Conns() { for _, c2 := range s.Conns() {
if c2.(*conn).rconn == c { if c2.(*conn).rconn == c {
@@ -89,8 +90,8 @@ func TestNotifications(t *testing.T) {
return nil, nil, nil return nil, nil, nil
} }
testOCStream := func(n *netNotifiee, s inet.Stream) { testOCStream := func(n *netNotifiee, s network.Stream) {
var s2 inet.Stream var s2 network.Stream
select { select {
case s2 = <-n.openedStream: case s2 = <-n.openedStream:
t.Log("got notif for opened stream") t.Log("got notif for opened stream")
@@ -113,8 +114,8 @@ func TestNotifications(t *testing.T) {
} }
for _, s := range nets { for _, s := range nets {
s.SetStreamHandler(func(s inet.Stream) { s.SetStreamHandler(func(s network.Stream) {
inet.FullClose(s) helpers.FullClose(s)
}) })
} }
@@ -127,11 +128,11 @@ func TestNotifications(t *testing.T) {
} }
} }
streams := make(chan inet.Stream) streams := make(chan network.Stream)
for _, s := range nets { for _, s := range nets {
s.SetStreamHandler(func(s inet.Stream) { s.SetStreamHandler(func(s network.Stream) {
streams <- s streams <- s
inet.FullClose(s) helpers.FullClose(s)
}) })
} }
@@ -146,7 +147,7 @@ func TestNotifications(t *testing.T) {
} else { } else {
t.Logf("%s %s <--%p--> %s %s", c.LocalPeer(), c.LocalMultiaddr(), st1, c.RemotePeer(), c.RemoteMultiaddr()) t.Logf("%s %s <--%p--> %s %s", c.LocalPeer(), c.LocalMultiaddr(), st1, c.RemotePeer(), c.RemoteMultiaddr())
// st1.Write([]byte("hello")) // st1.Write([]byte("hello"))
go inet.FullClose(st1) go helpers.FullClose(st1)
st2 := <-streams st2 := <-streams
t.Logf("%s %s <--%p--> %s %s", c2.LocalPeer(), c2.LocalMultiaddr(), st2, c2.RemotePeer(), c2.RemoteMultiaddr()) t.Logf("%s %s <--%p--> %s %s", c2.LocalPeer(), c2.LocalMultiaddr(), st2, c2.RemotePeer(), c2.RemoteMultiaddr())
testOCStream(notifiees[i], st1) testOCStream(notifiees[i], st1)
@@ -163,7 +164,7 @@ func TestNotifications(t *testing.T) {
c.(*conn).Close() c.(*conn).Close()
c2.Close() c2.Close()
var c3, c4 inet.Conn var c3, c4 network.Conn
select { select {
case c3 = <-n.disconnected: case c3 = <-n.disconnected:
case <-time.After(timeout): case <-time.After(timeout):
@@ -188,38 +189,38 @@ func TestNotifications(t *testing.T) {
type netNotifiee struct { type netNotifiee struct {
listen chan ma.Multiaddr listen chan ma.Multiaddr
listenClose chan ma.Multiaddr listenClose chan ma.Multiaddr
connected chan inet.Conn connected chan network.Conn
disconnected chan inet.Conn disconnected chan network.Conn
openedStream chan inet.Stream openedStream chan network.Stream
closedStream chan inet.Stream closedStream chan network.Stream
} }
func newNetNotifiee(buffer int) *netNotifiee { func newNetNotifiee(buffer int) *netNotifiee {
return &netNotifiee{ return &netNotifiee{
listen: make(chan ma.Multiaddr, buffer), listen: make(chan ma.Multiaddr, buffer),
listenClose: make(chan ma.Multiaddr, buffer), listenClose: make(chan ma.Multiaddr, buffer),
connected: make(chan inet.Conn, buffer), connected: make(chan network.Conn, buffer),
disconnected: make(chan inet.Conn, buffer), disconnected: make(chan network.Conn, buffer),
openedStream: make(chan inet.Stream, buffer), openedStream: make(chan network.Stream, buffer),
closedStream: make(chan inet.Stream, buffer), closedStream: make(chan network.Stream, buffer),
} }
} }
func (nn *netNotifiee) Listen(n inet.Network, a ma.Multiaddr) { func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr) {
nn.listen <- a nn.listen <- a
} }
func (nn *netNotifiee) ListenClose(n inet.Network, a ma.Multiaddr) { func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {
nn.listenClose <- a nn.listenClose <- a
} }
func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) { func (nn *netNotifiee) Connected(n network.Network, v network.Conn) {
nn.connected <- v nn.connected <- v
} }
func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) { func (nn *netNotifiee) Disconnected(n network.Network, v network.Conn) {
nn.disconnected <- v nn.disconnected <- v
} }
func (nn *netNotifiee) OpenedStream(n inet.Network, v inet.Stream) { func (nn *netNotifiee) OpenedStream(n network.Network, v network.Stream) {
nn.openedStream <- v nn.openedStream <- v
} }
func (nn *netNotifiee) ClosedStream(n inet.Network, v inet.Stream) { func (nn *netNotifiee) ClosedStream(n network.Network, v network.Stream) {
nn.closedStream <- v nn.closedStream <- v
} }

View File

@@ -6,20 +6,22 @@ import (
"math/rand" "math/rand"
"sync" "sync"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/jbenet/goprocess" "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
// peernet implements inet.Network // peernet implements network.Network
type peernet struct { type peernet struct {
mocknet *mocknet // parent mocknet *mocknet // parent
peer peer.ID peer peer.ID
ps pstore.Peerstore ps peerstore.Peerstore
// conns are actual live connections between peers. // conns are actual live connections between peers.
// many conns could run over each link. // many conns could run over each link.
@@ -27,19 +29,19 @@ type peernet struct {
connsByPeer map[peer.ID]map[*conn]struct{} connsByPeer map[peer.ID]map[*conn]struct{}
connsByLink map[*link]map[*conn]struct{} connsByLink map[*link]map[*conn]struct{}
// implement inet.Network // implement network.Network
streamHandler inet.StreamHandler streamHandler network.StreamHandler
connHandler inet.ConnHandler connHandler network.ConnHandler
notifmu sync.Mutex notifmu sync.Mutex
notifs map[inet.Notifiee]struct{} notifs map[network.Notifiee]struct{}
proc goprocess.Process proc goprocess.Process
sync.RWMutex sync.RWMutex
} }
// newPeernet constructs a new peernet // newPeernet constructs a new peernet
func newPeernet(ctx context.Context, m *mocknet, p peer.ID, ps pstore.Peerstore) (*peernet, error) { func newPeernet(ctx context.Context, m *mocknet, p peer.ID, ps peerstore.Peerstore) (*peernet, error) {
n := &peernet{ n := &peernet{
mocknet: m, mocknet: m,
@@ -49,7 +51,7 @@ func newPeernet(ctx context.Context, m *mocknet, p peer.ID, ps pstore.Peerstore)
connsByPeer: map[peer.ID]map[*conn]struct{}{}, connsByPeer: map[peer.ID]map[*conn]struct{}{},
connsByLink: map[*link]map[*conn]struct{}{}, connsByLink: map[*link]map[*conn]struct{}{},
notifs: make(map[inet.Notifiee]struct{}), notifs: make(map[network.Notifiee]struct{}),
} }
n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown) n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown)
@@ -83,7 +85,7 @@ func (pn *peernet) Close() error {
return pn.proc.Close() return pn.proc.Close()
} }
func (pn *peernet) Peerstore() pstore.Peerstore { func (pn *peernet) Peerstore() peerstore.Peerstore {
return pn.ps return pn.ps
} }
@@ -92,7 +94,7 @@ func (pn *peernet) String() string {
} }
// handleNewStream is an internal function to trigger the client's handler // handleNewStream is an internal function to trigger the client's handler
func (pn *peernet) handleNewStream(s inet.Stream) { func (pn *peernet) handleNewStream(s network.Stream) {
pn.RLock() pn.RLock()
handler := pn.streamHandler handler := pn.streamHandler
pn.RUnlock() pn.RUnlock()
@@ -102,7 +104,7 @@ func (pn *peernet) handleNewStream(s inet.Stream) {
} }
// handleNewConn is an internal function to trigger the client's handler // handleNewConn is an internal function to trigger the client's handler
func (pn *peernet) handleNewConn(c inet.Conn) { func (pn *peernet) handleNewConn(c network.Conn) {
pn.RLock() pn.RLock()
handler := pn.connHandler handler := pn.connHandler
pn.RUnlock() pn.RUnlock()
@@ -113,7 +115,7 @@ func (pn *peernet) handleNewConn(c inet.Conn) {
// DialPeer attempts to establish a connection to a given peer. // DialPeer attempts to establish a connection to a given peer.
// Respects the context. // Respects the context.
func (pn *peernet) DialPeer(ctx context.Context, p peer.ID) (inet.Conn, error) { func (pn *peernet) DialPeer(ctx context.Context, p peer.ID) (network.Conn, error) {
return pn.connect(p) return pn.connect(p)
} }
@@ -159,7 +161,7 @@ func (pn *peernet) openConn(r peer.ID, l *link) *conn {
lc, rc := l.newConnPair(pn) lc, rc := l.newConnPair(pn)
log.Debugf("%s opening connection to %s", pn.LocalPeer(), lc.RemotePeer()) log.Debugf("%s opening connection to %s", pn.LocalPeer(), lc.RemotePeer())
pn.addConn(lc) pn.addConn(lc)
pn.notifyAll(func(n inet.Notifiee) { pn.notifyAll(func(n network.Notifiee) {
n.Connected(pn, lc) n.Connected(pn, lc)
}) })
rc.net.remoteOpenedConn(rc) rc.net.remoteOpenedConn(rc)
@@ -170,7 +172,7 @@ func (pn *peernet) remoteOpenedConn(c *conn) {
log.Debugf("%s accepting connection from %s", pn.LocalPeer(), c.RemotePeer()) log.Debugf("%s accepting connection from %s", pn.LocalPeer(), c.RemotePeer())
pn.addConn(c) pn.addConn(c)
pn.handleNewConn(c) pn.handleNewConn(c)
pn.notifyAll(func(n inet.Notifiee) { pn.notifyAll(func(n network.Notifiee) {
n.Connected(pn, c) n.Connected(pn, c)
}) })
} }
@@ -240,11 +242,11 @@ func (pn *peernet) Peers() []peer.ID {
} }
// Conns returns all the connections of this peer // Conns returns all the connections of this peer
func (pn *peernet) Conns() []inet.Conn { func (pn *peernet) Conns() []network.Conn {
pn.RLock() pn.RLock()
defer pn.RUnlock() defer pn.RUnlock()
out := make([]inet.Conn, 0, len(pn.connsByPeer)) out := make([]network.Conn, 0, len(pn.connsByPeer))
for _, cs := range pn.connsByPeer { for _, cs := range pn.connsByPeer {
for c := range cs { for c := range cs {
out = append(out, c) out = append(out, c)
@@ -253,7 +255,7 @@ func (pn *peernet) Conns() []inet.Conn {
return out return out
} }
func (pn *peernet) ConnsToPeer(p peer.ID) []inet.Conn { func (pn *peernet) ConnsToPeer(p peer.ID) []network.Conn {
pn.RLock() pn.RLock()
defer pn.RUnlock() defer pn.RUnlock()
@@ -262,7 +264,7 @@ func (pn *peernet) ConnsToPeer(p peer.ID) []inet.Conn {
return nil return nil
} }
var cs2 []inet.Conn var cs2 []network.Conn
for c := range cs { for c := range cs {
cs2 = append(cs2, c) cs2 = append(cs2, c)
} }
@@ -298,7 +300,7 @@ func (pn *peernet) BandwidthTotals() (in uint64, out uint64) {
// Listen tells the network to start listening on given multiaddrs. // Listen tells the network to start listening on given multiaddrs.
func (pn *peernet) Listen(addrs ...ma.Multiaddr) error { func (pn *peernet) Listen(addrs ...ma.Multiaddr) error {
pn.Peerstore().AddAddrs(pn.LocalPeer(), addrs, pstore.PermanentAddrTTL) pn.Peerstore().AddAddrs(pn.LocalPeer(), addrs, peerstore.PermanentAddrTTL)
return nil return nil
} }
@@ -316,20 +318,20 @@ func (pn *peernet) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
// Connectedness returns a state signaling connection capabilities // Connectedness returns a state signaling connection capabilities
// For now only returns Connecter || NotConnected. Expand into more later. // For now only returns Connecter || NotConnected. Expand into more later.
func (pn *peernet) Connectedness(p peer.ID) inet.Connectedness { func (pn *peernet) Connectedness(p peer.ID) network.Connectedness {
pn.Lock() pn.Lock()
defer pn.Unlock() defer pn.Unlock()
cs, found := pn.connsByPeer[p] cs, found := pn.connsByPeer[p]
if found && len(cs) > 0 { if found && len(cs) > 0 {
return inet.Connected return network.Connected
} }
return inet.NotConnected return network.NotConnected
} }
// NewStream returns a new stream to given peer p. // NewStream returns a new stream to given peer p.
// If there is no connection to p, attempts to create one. // If there is no connection to p, attempts to create one.
func (pn *peernet) NewStream(ctx context.Context, p peer.ID) (inet.Stream, error) { func (pn *peernet) NewStream(ctx context.Context, p peer.ID) (network.Stream, error) {
c, err := pn.DialPeer(ctx, p) c, err := pn.DialPeer(ctx, p)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -339,7 +341,7 @@ func (pn *peernet) NewStream(ctx context.Context, p peer.ID) (inet.Stream, error
// SetStreamHandler sets the new stream handler on the Network. // SetStreamHandler sets the new stream handler on the Network.
// This operation is threadsafe. // This operation is threadsafe.
func (pn *peernet) SetStreamHandler(h inet.StreamHandler) { func (pn *peernet) SetStreamHandler(h network.StreamHandler) {
pn.Lock() pn.Lock()
pn.streamHandler = h pn.streamHandler = h
pn.Unlock() pn.Unlock()
@@ -347,35 +349,35 @@ func (pn *peernet) SetStreamHandler(h inet.StreamHandler) {
// SetConnHandler sets the new conn handler on the Network. // SetConnHandler sets the new conn handler on the Network.
// This operation is threadsafe. // This operation is threadsafe.
func (pn *peernet) SetConnHandler(h inet.ConnHandler) { func (pn *peernet) SetConnHandler(h network.ConnHandler) {
pn.Lock() pn.Lock()
pn.connHandler = h pn.connHandler = h
pn.Unlock() pn.Unlock()
} }
// Notify signs up Notifiee to receive signals when events happen // Notify signs up Notifiee to receive signals when events happen
func (pn *peernet) Notify(f inet.Notifiee) { func (pn *peernet) Notify(f network.Notifiee) {
pn.notifmu.Lock() pn.notifmu.Lock()
pn.notifs[f] = struct{}{} pn.notifs[f] = struct{}{}
pn.notifmu.Unlock() pn.notifmu.Unlock()
} }
// StopNotify unregisters Notifiee from receiving signals // StopNotify unregisters Notifiee from receiving signals
func (pn *peernet) StopNotify(f inet.Notifiee) { func (pn *peernet) StopNotify(f network.Notifiee) {
pn.notifmu.Lock() pn.notifmu.Lock()
delete(pn.notifs, f) delete(pn.notifs, f)
pn.notifmu.Unlock() pn.notifmu.Unlock()
} }
// notifyAll runs the notification function on all Notifiees // notifyAll runs the notification function on all Notifiees
func (pn *peernet) notifyAll(notification func(f inet.Notifiee)) { func (pn *peernet) notifyAll(notification func(f network.Notifiee)) {
pn.notifmu.Lock() pn.notifmu.Lock()
var wg sync.WaitGroup var wg sync.WaitGroup
for n := range pn.notifs { for n := range pn.notifs {
// make sure we dont block // make sure we dont block
// and they dont block each other. // and they dont block each other.
wg.Add(1) wg.Add(1)
go func(n inet.Notifiee) { go func(n network.Notifiee) {
defer wg.Done() defer wg.Done()
notification(n) notification(n)
}(n) }(n)

View File

@@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"io" "io"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
) )
// separate object so our interfaces are separate :) // separate object so our interfaces are separate :)
@@ -26,7 +26,7 @@ func (p *printer) MocknetLinks(mn Mocknet) {
fmt.Fprintf(p.w, "\n") fmt.Fprintf(p.w, "\n")
} }
func (p *printer) NetworkConns(ni inet.Network) { func (p *printer) NetworkConns(ni network.Network) {
fmt.Fprintf(p.w, "%s connected to:\n", ni.LocalPeer()) fmt.Fprintf(p.w, "%s connected to:\n", ni.LocalPeer())
for _, c := range ni.Conns() { for _, c := range ni.Conns() {

View File

@@ -8,11 +8,11 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-core/protocol"
) )
// stream implements inet.Stream // stream implements network.Stream
type stream struct { type stream struct {
write *io.PipeWriter write *io.PipeWriter
read *io.PipeReader read *io.PipeReader
@@ -26,7 +26,7 @@ type stream struct {
writeErr error writeErr error
protocol atomic.Value protocol atomic.Value
stat inet.Stat stat network.Stat
} }
var ErrReset error = errors.New("stream reset") var ErrReset error = errors.New("stream reset")
@@ -37,7 +37,7 @@ type transportObject struct {
arrivalTime time.Time arrivalTime time.Time
} }
func NewStream(w *io.PipeWriter, r *io.PipeReader, dir inet.Direction) *stream { func NewStream(w *io.PipeWriter, r *io.PipeReader, dir network.Direction) *stream {
s := &stream{ s := &stream{
read: r, read: r,
write: w, write: w,
@@ -45,7 +45,7 @@ func NewStream(w *io.PipeWriter, r *io.PipeReader, dir inet.Direction) *stream {
close: make(chan struct{}, 1), close: make(chan struct{}, 1),
closed: make(chan struct{}), closed: make(chan struct{}),
toDeliver: make(chan *transportObject), toDeliver: make(chan *transportObject),
stat: inet.Stat{Direction: dir}, stat: network.Stat{Direction: dir},
} }
go s.transport() go s.transport()
@@ -76,7 +76,7 @@ func (s *stream) Protocol() protocol.ID {
return p return p
} }
func (s *stream) Stat() inet.Stat { func (s *stream) Stat() network.Stat {
return s.stat return s.stat
} }
@@ -118,12 +118,12 @@ func (s *stream) teardown() {
// Mark as closed. // Mark as closed.
close(s.closed) close(s.closed)
s.conn.net.notifyAll(func(n inet.Notifiee) { s.conn.net.notifyAll(func(n network.Notifiee) {
n.ClosedStream(s.conn.net, s) n.ClosedStream(s.conn.net, s)
}) })
} }
func (s *stream) Conn() inet.Conn { func (s *stream) Conn() network.Conn {
return s.conn return s.conn
} }

View File

@@ -10,15 +10,18 @@ import (
"testing" "testing"
"time" "time"
ci "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-core/test"
detectrace "github.com/ipfs/go-detect-race" detectrace "github.com/ipfs/go-detect-race"
inet "github.com/libp2p/go-libp2p-net" tnet "github.com/libp2p/go-libp2p-testing/net"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
testutil "github.com/libp2p/go-testutil"
) )
func randPeer(t *testing.T) peer.ID { func randPeer(t *testing.T) peer.ID {
p, err := testutil.RandPeerID() p, err := test.RandPeerID()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -28,15 +31,15 @@ func randPeer(t *testing.T) peer.ID {
func TestNetworkSetup(t *testing.T) { func TestNetworkSetup(t *testing.T) {
ctx := context.Background() ctx := context.Background()
sk1, _, err := testutil.RandTestKeyPair(512) sk1, _, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil { if err != nil {
t.Fatal(t) t.Fatal(t)
} }
sk2, _, err := testutil.RandTestKeyPair(512) sk2, _, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil { if err != nil {
t.Fatal(t) t.Fatal(t)
} }
sk3, _, err := testutil.RandTestKeyPair(512) sk3, _, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil { if err != nil {
t.Fatal(t) t.Fatal(t)
} }
@@ -45,9 +48,9 @@ func TestNetworkSetup(t *testing.T) {
// add peers to mock net // add peers to mock net
a1 := testutil.RandLocalTCPAddress() a1 := tnet.RandLocalTCPAddress()
a2 := testutil.RandLocalTCPAddress() a2 := tnet.RandLocalTCPAddress()
a3 := testutil.RandLocalTCPAddress() a3 := tnet.RandLocalTCPAddress()
h1, err := mn.AddPeer(sk1, a1) h1, err := mn.AddPeer(sk1, a1)
if err != nil { if err != nil {
@@ -278,7 +281,7 @@ func TestStreams(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
handler := func(s inet.Stream) { handler := func(s network.Stream) {
b := make([]byte, 4) b := make([]byte, 4)
if _, err := io.ReadFull(s, b); err != nil { if _, err := io.ReadFull(s, b); err != nil {
panic(err) panic(err)
@@ -315,8 +318,8 @@ func TestStreams(t *testing.T) {
} }
func makePinger(st string, n int) func(inet.Stream) { func makePinger(st string, n int) func(network.Stream) {
return func(s inet.Stream) { return func(s network.Stream) {
go func() { go func() {
defer s.Close() defer s.Close()
@@ -336,8 +339,8 @@ func makePinger(st string, n int) func(inet.Stream) {
} }
} }
func makePonger(st string) func(inet.Stream) { func makePonger(st string) func(network.Stream) {
return func(s inet.Stream) { return func(s network.Stream) {
go func() { go func() {
defer s.Close() defer s.Close()
@@ -409,12 +412,12 @@ func TestAdding(t *testing.T) {
peers := []peer.ID{} peers := []peer.ID{}
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
sk, _, err := testutil.RandTestKeyPair(512) sk, _, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
a := testutil.RandLocalTCPAddress() a := tnet.RandLocalTCPAddress()
h, err := mn.AddPeer(sk, a) h, err := mn.AddPeer(sk, a)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -440,7 +443,7 @@ func TestAdding(t *testing.T) {
if h2 == nil { if h2 == nil {
t.Fatalf("no host for %s", p2) t.Fatalf("no host for %s", p2)
} }
h2.SetStreamHandler(protocol.TestingID, func(s inet.Stream) { h2.SetStreamHandler(protocol.TestingID, func(s network.Stream) {
defer s.Close() defer s.Close()
b := make([]byte, 4) b := make([]byte, 4)
@@ -535,7 +538,7 @@ func TestLimitedStreams(t *testing.T) {
var wg sync.WaitGroup var wg sync.WaitGroup
messages := 4 messages := 4
messageSize := 500 messageSize := 500
handler := func(s inet.Stream) { handler := func(s network.Stream) {
b := make([]byte, messageSize) b := make([]byte, messageSize)
for i := 0; i < messages; i++ { for i := 0; i < messages; i++ {
if _, err := io.ReadFull(s, b); err != nil { if _, err := io.ReadFull(s, b); err != nil {
@@ -619,7 +622,7 @@ func TestStreamsWithLatency(t *testing.T) {
// we'll write once to a single stream // we'll write once to a single stream
wg.Add(1) wg.Add(1)
handler := func(s inet.Stream) { handler := func(s network.Stream) {
b := make([]byte, mln) b := make([]byte, mln)
if _, err := io.ReadFull(s, b); err != nil { if _, err := io.ReadFull(s, b); err != nil {

View File

@@ -5,16 +5,20 @@ import (
"sync" "sync"
"time" "time"
ic "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb" pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb"
ggio "github.com/gogo/protobuf/io" ggio "github.com/gogo/protobuf/io"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
ic "github.com/libp2p/go-libp2p-crypto"
host "github.com/libp2p/go-libp2p-host"
lgbl "github.com/libp2p/go-libp2p-loggables" lgbl "github.com/libp2p/go-libp2p-loggables"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
msmux "github.com/multiformats/go-multistream" msmux "github.com/multiformats/go-multistream"
) )
@@ -51,7 +55,7 @@ type IDService struct {
// connections undergoing identification // connections undergoing identification
// for wait purposes // for wait purposes
currid map[inet.Conn]chan struct{} currid map[network.Conn]chan struct{}
currmu sync.RWMutex currmu sync.RWMutex
addrMu sync.Mutex addrMu sync.Mutex
@@ -67,7 +71,7 @@ func NewIDService(ctx context.Context, h host.Host) *IDService {
s := &IDService{ s := &IDService{
Host: h, Host: h,
ctx: ctx, ctx: ctx,
currid: make(map[inet.Conn]chan struct{}), currid: make(map[network.Conn]chan struct{}),
observedAddrs: NewObservedAddrSet(ctx), observedAddrs: NewObservedAddrSet(ctx),
} }
h.SetStreamHandler(ID, s.requestHandler) h.SetStreamHandler(ID, s.requestHandler)
@@ -85,7 +89,7 @@ func (ids *IDService) ObservedAddrsFor(local ma.Multiaddr) []ma.Multiaddr {
return ids.observedAddrs.AddrsFor(local) return ids.observedAddrs.AddrsFor(local)
} }
func (ids *IDService) IdentifyConn(c inet.Conn) { func (ids *IDService) IdentifyConn(c network.Conn) {
ids.currmu.Lock() ids.currmu.Lock()
if wait, found := ids.currid[c]; found { if wait, found := ids.currid[c]; found {
ids.currmu.Unlock() ids.currmu.Unlock()
@@ -124,8 +128,8 @@ func (ids *IDService) IdentifyConn(c inet.Conn) {
ids.responseHandler(s) ids.responseHandler(s)
} }
func (ids *IDService) requestHandler(s inet.Stream) { func (ids *IDService) requestHandler(s network.Stream) {
defer inet.FullClose(s) defer helpers.FullClose(s)
c := s.Conn() c := s.Conn()
w := ggio.NewDelimitedWriter(s) w := ggio.NewDelimitedWriter(s)
@@ -137,7 +141,7 @@ func (ids *IDService) requestHandler(s inet.Stream) {
c.RemotePeer(), c.RemoteMultiaddr()) c.RemotePeer(), c.RemoteMultiaddr())
} }
func (ids *IDService) responseHandler(s inet.Stream) { func (ids *IDService) responseHandler(s network.Stream) {
c := s.Conn() c := s.Conn()
r := ggio.NewDelimitedReader(s, 2048) r := ggio.NewDelimitedReader(s, 2048)
@@ -151,10 +155,10 @@ func (ids *IDService) responseHandler(s inet.Stream) {
log.Debugf("%s received message from %s %s", ID, log.Debugf("%s received message from %s %s", ID,
c.RemotePeer(), c.RemoteMultiaddr()) c.RemotePeer(), c.RemoteMultiaddr())
go inet.FullClose(s) go helpers.FullClose(s)
} }
func (ids *IDService) pushHandler(s inet.Stream) { func (ids *IDService) pushHandler(s network.Stream) {
ids.responseHandler(s) ids.responseHandler(s)
} }
@@ -162,7 +166,7 @@ func (ids *IDService) Push() {
var wg sync.WaitGroup var wg sync.WaitGroup
ctx, cancel := context.WithTimeout(ids.ctx, 30*time.Second) ctx, cancel := context.WithTimeout(ids.ctx, 30*time.Second)
ctx = inet.WithNoDial(ctx, "identify push") ctx = network.WithNoDial(ctx, "identify push")
for _, p := range ids.Host.Network().Peers() { for _, p := range ids.Host.Network().Peers() {
wg.Add(1) wg.Add(1)
@@ -197,7 +201,7 @@ func (ids *IDService) Push() {
}() }()
} }
func (ids *IDService) populateMessage(mes *pb.Identify, c inet.Conn) { func (ids *IDService) populateMessage(mes *pb.Identify, c network.Conn) {
// set protocols this node is currently handling // set protocols this node is currently handling
protos := ids.Host.Mux().Protocols() protos := ids.Host.Mux().Protocols()
@@ -246,7 +250,7 @@ func (ids *IDService) populateMessage(mes *pb.Identify, c inet.Conn) {
mes.AgentVersion = &av mes.AgentVersion = &av
} }
func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) { func (ids *IDService) consumeMessage(mes *pb.Identify, c network.Conn) {
p := c.RemotePeer() p := c.RemotePeer()
// mes.Protocols // mes.Protocols
@@ -280,14 +284,14 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
// Taking the lock ensures that we don't concurrently process a disconnect. // Taking the lock ensures that we don't concurrently process a disconnect.
ids.addrMu.Lock() ids.addrMu.Lock()
switch ids.Host.Network().Connectedness(p) { switch ids.Host.Network().Connectedness(p) {
case inet.Connected: case network.Connected:
// invalidate previous addrs -- we use a transient ttl instead of 0 to ensure there // invalidate previous addrs -- we use a transient ttl instead of 0 to ensure there
// is no period of having no good addrs whatsoever // is no period of having no good addrs whatsoever
ids.Host.Peerstore().UpdateAddrs(p, pstore.ConnectedAddrTTL, transientTTL) ids.Host.Peerstore().UpdateAddrs(p, peerstore.ConnectedAddrTTL, transientTTL)
ids.Host.Peerstore().AddAddrs(p, lmaddrs, pstore.ConnectedAddrTTL) ids.Host.Peerstore().AddAddrs(p, lmaddrs, peerstore.ConnectedAddrTTL)
default: default:
ids.Host.Peerstore().UpdateAddrs(p, pstore.ConnectedAddrTTL, transientTTL) ids.Host.Peerstore().UpdateAddrs(p, peerstore.ConnectedAddrTTL, transientTTL)
ids.Host.Peerstore().AddAddrs(p, lmaddrs, pstore.RecentlyConnectedAddrTTL) ids.Host.Peerstore().AddAddrs(p, lmaddrs, peerstore.RecentlyConnectedAddrTTL)
} }
ids.addrMu.Unlock() ids.addrMu.Unlock()
@@ -304,7 +308,7 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
ids.consumeReceivedPubKey(c, mes.PublicKey) ids.consumeReceivedPubKey(c, mes.PublicKey)
} }
func (ids *IDService) consumeReceivedPubKey(c inet.Conn, kb []byte) { func (ids *IDService) consumeReceivedPubKey(c network.Conn, kb []byte) {
lp := c.LocalPeer() lp := c.LocalPeer()
rp := c.RemotePeer() rp := c.RemotePeer()
@@ -412,7 +416,7 @@ func HasConsistentTransport(a ma.Multiaddr, green []ma.Multiaddr) bool {
// This happens async so the connection can start to be used // This happens async so the connection can start to be used
// even if handshake3 knowledge is not necesary. // even if handshake3 knowledge is not necesary.
// Users **MUST** call IdentifyWait _after_ IdentifyConn // Users **MUST** call IdentifyWait _after_ IdentifyConn
func (ids *IDService) IdentifyWait(c inet.Conn) <-chan struct{} { func (ids *IDService) IdentifyWait(c network.Conn) <-chan struct{} {
ids.currmu.Lock() ids.currmu.Lock()
ch, found := ids.currid[c] ch, found := ids.currid[c]
ids.currmu.Unlock() ids.currmu.Unlock()
@@ -427,7 +431,7 @@ func (ids *IDService) IdentifyWait(c inet.Conn) <-chan struct{} {
return ch return ch
} }
func (ids *IDService) consumeObservedAddress(observed []byte, c inet.Conn) { func (ids *IDService) consumeObservedAddress(observed []byte, c network.Conn) {
if observed == nil { if observed == nil {
return return
} }
@@ -481,30 +485,30 @@ func (nn *netNotifiee) IDService() *IDService {
return (*IDService)(nn) return (*IDService)(nn)
} }
func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) { func (nn *netNotifiee) Connected(n network.Network, v network.Conn) {
// TODO: deprecate the setConnHandler hook, and kick off // TODO: deprecate the setConnHandler hook, and kick off
// identification here. // identification here.
} }
func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) { func (nn *netNotifiee) Disconnected(n network.Network, v network.Conn) {
// undo the setting of addresses to peer.ConnectedAddrTTL we did // undo the setting of addresses to peer.ConnectedAddrTTL we did
ids := nn.IDService() ids := nn.IDService()
ids.addrMu.Lock() ids.addrMu.Lock()
defer ids.addrMu.Unlock() defer ids.addrMu.Unlock()
if ids.Host.Network().Connectedness(v.RemotePeer()) != inet.Connected { if ids.Host.Network().Connectedness(v.RemotePeer()) != network.Connected {
// Last disconnect. // Last disconnect.
ps := ids.Host.Peerstore() ps := ids.Host.Peerstore()
ps.UpdateAddrs(v.RemotePeer(), pstore.ConnectedAddrTTL, pstore.RecentlyConnectedAddrTTL) ps.UpdateAddrs(v.RemotePeer(), peerstore.ConnectedAddrTTL, peerstore.RecentlyConnectedAddrTTL)
} }
} }
func (nn *netNotifiee) OpenedStream(n inet.Network, v inet.Stream) {} func (nn *netNotifiee) OpenedStream(n network.Network, v network.Stream) {}
func (nn *netNotifiee) ClosedStream(n inet.Network, v inet.Stream) {} func (nn *netNotifiee) ClosedStream(n network.Network, v network.Stream) {}
func (nn *netNotifiee) Listen(n inet.Network, a ma.Multiaddr) {} func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr) {}
func (nn *netNotifiee) ListenClose(n inet.Network, a ma.Multiaddr) {} func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {}
func logProtocolMismatchDisconnect(c inet.Conn, protocol, agent string) { func logProtocolMismatchDisconnect(c network.Conn, protocol, agent string) {
lm := make(lgbl.DeferredMap) lm := make(lgbl.DeferredMap)
lm["remotePeer"] = func() interface{} { return c.RemotePeer().Pretty() } lm["remotePeer"] = func() interface{} { return c.RemotePeer().Pretty() }
lm["remoteAddr"] = func() interface{} { return c.RemoteMultiaddr().String() } lm["remoteAddr"] = func() interface{} { return c.RemoteMultiaddr().String() }

View File

@@ -5,14 +5,15 @@ import (
"testing" "testing"
"time" "time"
ic "github.com/libp2p/go-libp2p-crypto" ic "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/host"
pstore "github.com/libp2p/go-libp2p-peerstore" "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
blhost "github.com/libp2p/go-libp2p-blankhost"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify" identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
blhost "github.com/libp2p/go-libp2p-blankhost"
host "github.com/libp2p/go-libp2p-host"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -34,7 +35,7 @@ func subtestIDService(t *testing.T) {
forgetMe, _ := ma.NewMultiaddr("/ip4/1.2.3.4/tcp/1234") forgetMe, _ := ma.NewMultiaddr("/ip4/1.2.3.4/tcp/1234")
h2.Peerstore().AddAddr(h1p, forgetMe, pstore.RecentlyConnectedAddrTTL) h2.Peerstore().AddAddr(h1p, forgetMe, peerstore.RecentlyConnectedAddrTTL)
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
h2pi := h2.Peerstore().PeerInfo(h2p) h2pi := h2.Peerstore().PeerInfo(h2p)
@@ -155,10 +156,10 @@ func testHasPublicKey(t *testing.T, h host.Host, p peer.ID, shouldBe ic.PubKey)
// this is becasue it used to be concurrent. Now, Dial wait till the // this is becasue it used to be concurrent. Now, Dial wait till the
// id service is done. // id service is done.
func TestIDService(t *testing.T) { func TestIDService(t *testing.T) {
oldTTL := pstore.RecentlyConnectedAddrTTL oldTTL := peerstore.RecentlyConnectedAddrTTL
pstore.RecentlyConnectedAddrTTL = time.Second peerstore.RecentlyConnectedAddrTTL = time.Second
defer func() { defer func() {
pstore.RecentlyConnectedAddrTTL = oldTTL peerstore.RecentlyConnectedAddrTTL = oldTTL
}() }()
N := 3 N := 3

View File

@@ -5,8 +5,9 @@ import (
"sync" "sync"
"time" "time"
net "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
pstore "github.com/libp2p/go-libp2p-peerstore" "github.com/libp2p/go-libp2p-core/peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@@ -16,7 +17,7 @@ var GCInterval = 10 * time.Minute
type observation struct { type observation struct {
seenTime time.Time seenTime time.Time
connDirection net.Direction connDirection network.Direction
} }
// ObservedAddr is an entry for an address reported by our peers. // ObservedAddr is an entry for an address reported by our peers.
@@ -38,7 +39,7 @@ func (oa *ObservedAddr) activated(ttl time.Duration) bool {
type newObservation struct { type newObservation struct {
observed, local, observer ma.Multiaddr observed, local, observer ma.Multiaddr
direction net.Direction direction network.Direction
} }
// ObservedAddrSet keeps track of a set of ObservedAddrs // ObservedAddrSet keeps track of a set of ObservedAddrs
@@ -57,7 +58,7 @@ type ObservedAddrSet struct {
func NewObservedAddrSet(ctx context.Context) *ObservedAddrSet { func NewObservedAddrSet(ctx context.Context) *ObservedAddrSet {
oas := &ObservedAddrSet{ oas := &ObservedAddrSet{
addrs: make(map[string][]*ObservedAddr), addrs: make(map[string][]*ObservedAddr),
ttl: pstore.OwnObservedAddrTTL, ttl: peerstore.OwnObservedAddrTTL,
wch: make(chan newObservation, 16), wch: make(chan newObservation, 16),
} }
go oas.worker(ctx) go oas.worker(ctx)
@@ -111,7 +112,7 @@ func (oas *ObservedAddrSet) Addrs() (addrs []ma.Multiaddr) {
} }
func (oas *ObservedAddrSet) Add(observed, local, observer ma.Multiaddr, func (oas *ObservedAddrSet) Add(observed, local, observer ma.Multiaddr,
direction net.Direction) { direction network.Direction) {
select { select {
case oas.wch <- newObservation{observed: observed, local: local, observer: observer, direction: direction}: case oas.wch <- newObservation{observed: observed, local: local, observer: observer, direction: direction}:
default: default:
@@ -168,7 +169,7 @@ func (oas *ObservedAddrSet) gc() {
} }
func (oas *ObservedAddrSet) doAdd(observed, local, observer ma.Multiaddr, func (oas *ObservedAddrSet) doAdd(observed, local, observer ma.Multiaddr,
direction net.Direction) { direction network.Direction) {
now := time.Now() now := time.Now()
observerString := observerGroup(observer) observerString := observerGroup(observer)

View File

@@ -7,7 +7,7 @@ import (
"time" "time"
detectrace "github.com/ipfs/go-detect-race" detectrace "github.com/ipfs/go-detect-race"
net "github.com/libp2p/go-libp2p-net" net "github.com/libp2p/go-libp2p-core/network"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )

View File

@@ -9,9 +9,9 @@ import (
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
) )
var log = logging.Logger("ping") var log = logging.Logger("ping")
@@ -32,7 +32,7 @@ func NewPingService(h host.Host) *PingService {
return ps return ps
} }
func (p *PingService) PingHandler(s inet.Stream) { func (p *PingService) PingHandler(s network.Stream) {
buf := make([]byte, PingSize) buf := make([]byte, PingSize)
errCh := make(chan error, 1) errCh := make(chan error, 1)
@@ -129,7 +129,7 @@ func Ping(ctx context.Context, h host.Host, p peer.ID) <-chan Result {
return out return out
} }
func ping(s inet.Stream) (time.Duration, error) { func ping(s network.Stream) (time.Duration, error) {
buf := make([]byte, PingSize) buf := make([]byte, PingSize)
u.NewTimeSeededRand().Read(buf) u.NewTimeSeededRand().Read(buf)

View File

@@ -5,8 +5,8 @@ import (
"testing" "testing"
"time" "time"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic" bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
ping "github.com/libp2p/go-libp2p/p2p/protocol/ping" ping "github.com/libp2p/go-libp2p/p2p/protocol/ping"
@@ -18,7 +18,7 @@ func TestPing(t *testing.T) {
h1 := bhost.New(swarmt.GenSwarm(t, ctx)) h1 := bhost.New(swarmt.GenSwarm(t, ctx))
h2 := bhost.New(swarmt.GenSwarm(t, ctx)) h2 := bhost.New(swarmt.GenSwarm(t, ctx))
err := h1.Connect(ctx, pstore.PeerInfo{ err := h1.Connect(ctx, peer.AddrInfo{
ID: h2.ID(), ID: h2.ID(),
Addrs: h2.Addrs(), Addrs: h2.Addrs(),
}) })

View File

@@ -11,10 +11,10 @@ import (
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer" "github.com/libp2p/go-libp2p-core/peer"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-core/protocol"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
) )
@@ -59,7 +59,7 @@ a problem.
senderDone := make(chan struct{}) senderDone := make(chan struct{})
// the receiver handles requests with some rate limiting // the receiver handles requests with some rate limiting
receiver := func(s inet.Stream) { receiver := func(s network.Stream) {
log.Debug("receiver received a stream") log.Debug("receiver received a stream")
<-receiverRatelimit // acquire <-receiverRatelimit // acquire
@@ -76,7 +76,7 @@ a problem.
// the sender opens streams as fast as possible // the sender opens streams as fast as possible
sender := func(host host.Host, remote peer.ID) { sender := func(host host.Host, remote peer.ID) {
var s inet.Stream var s network.Stream
var err error var err error
defer func() { defer func() {
t.Error(err) t.Error(err)
@@ -230,7 +230,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
// completion of every write. This makes it possible to see how // completion of every write. This makes it possible to see how
// fast it's actually writing. We pair this with a receiver // fast it's actually writing. We pair this with a receiver
// that waits for a signal to read. // that waits for a signal to read.
sender := func(s inet.Stream) { sender := func(s network.Stream) {
defer func() { defer func() {
s.Close() s.Close()
senderDone <- struct{}{} senderDone <- struct{}{}
@@ -263,7 +263,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
// receive a number of bytes from a stream. // receive a number of bytes from a stream.
// returns the number of bytes written. // returns the number of bytes written.
receive := func(s inet.Stream, expect int) { receive := func(s network.Stream, expect int) {
t.Helper() t.Helper()
log.Debugf("receiver to read %d bytes", expect) log.Debugf("receiver to read %d bytes", expect)
rbuf := make([]byte, expect) rbuf := make([]byte, expect)

View File

@@ -12,15 +12,15 @@ import (
u "github.com/ipfs/go-ipfs-util" u "github.com/ipfs/go-ipfs-util"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p-host" "github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-net" "github.com/libp2p/go-libp2p-core/network"
protocol "github.com/libp2p/go-libp2p-protocol" protocol "github.com/libp2p/go-libp2p-core/protocol"
swarmt "github.com/libp2p/go-libp2p-swarm/testing" swarmt "github.com/libp2p/go-libp2p-swarm/testing"
) )
var log = logging.Logger("reconnect") var log = logging.Logger("reconnect")
func EchoStreamHandler(stream inet.Stream) { func EchoStreamHandler(stream network.Stream) {
c := stream.Conn() c := stream.Conn()
log.Debugf("%s echoing %s", c.LocalPeer(), c.RemotePeer()) log.Debugf("%s echoing %s", c.LocalPeer(), c.RemotePeer())
go func() { go func() {
@@ -51,9 +51,9 @@ func newSendChans() sendChans {
} }
} }
func newSender() (chan sendChans, func(s inet.Stream)) { func newSender() (chan sendChans, func(s network.Stream)) {
scc := make(chan sendChans) scc := make(chan sendChans)
return scc, func(s inet.Stream) { return scc, func(s network.Stream) {
sc := newSendChans() sc := newSendChans()
scc <- sc scc <- sc