Skip to content

Commit

Permalink
migrate to consolidated types. (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk authored May 26, 2019
1 parent 08ddcf7 commit 49274b0
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 155 deletions.
2 changes: 1 addition & 1 deletion blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pubsub

import (
lru "github.com/hashicorp/golang-lru"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/peer"
)

// Blacklist is an interface for peer blacklisting.
Expand Down
2 changes: 1 addition & 1 deletion blacklist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/peer"
)

func TestMapBlacklist(t *testing.T) {
Expand Down
16 changes: 9 additions & 7 deletions comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"context"
"io"

pb "github.com/libp2p/go-libp2p-pubsub/pb"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"

ggio "github.com/gogo/protobuf/io"
proto "github.com/gogo/protobuf/proto"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
pb "github.com/libp2p/go-libp2p-pubsub/pb"

ms "github.com/multiformats/go-multistream"
)

Expand All @@ -27,7 +29,7 @@ func (p *PubSub) getHelloPacket() *RPC {
return &rpc
}

func (p *PubSub) handleNewStream(s inet.Stream) {
func (p *PubSub) handleNewStream(s network.Stream) {
r := ggio.NewDelimitedReader(s, 1<<20)
for {
rpc := new(RPC)
Expand Down Expand Up @@ -82,7 +84,7 @@ func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan
}
}

func (p *PubSub) handlePeerEOF(ctx context.Context, s inet.Stream) {
func (p *PubSub) handlePeerEOF(ctx context.Context, s network.Stream) {
r := ggio.NewDelimitedReader(s, 1<<20)
rpc := new(RPC)
for {
Expand All @@ -98,7 +100,7 @@ func (p *PubSub) handlePeerEOF(ctx context.Context, s inet.Stream) {
}
}

func (p *PubSub) handleSendingMessages(ctx context.Context, s inet.Stream, outgoing <-chan *RPC) {
func (p *PubSub) handleSendingMessages(ctx context.Context, s network.Stream, outgoing <-chan *RPC) {
bufw := bufio.NewWriter(s)
wc := ggio.NewDelimitedWriter(bufw)

Expand All @@ -111,7 +113,7 @@ func (p *PubSub) handleSendingMessages(ctx context.Context, s inet.Stream, outgo
return bufw.Flush()
}

defer inet.FullClose(s)
defer helpers.FullClose(s)
for {
select {
case rpc, ok := <-outgoing:
Expand Down
6 changes: 3 additions & 3 deletions floodsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions floodsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
"time"

bhost "github.com/libp2p/go-libp2p-blankhost"
host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"

swarmt "github.com/libp2p/go-libp2p-swarm/testing"
)

Expand Down
22 changes: 4 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
module github.com/libp2p/go-libp2p-pubsub

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.2.1
github.com/golang/protobuf v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.1
github.com/ipfs/go-log v0.0.1
github.com/libp2p/go-libp2p-blankhost v0.0.1
github.com/libp2p/go-libp2p-crypto v0.0.2
github.com/libp2p/go-libp2p-host v0.0.3
github.com/libp2p/go-libp2p-interface-connmgr v0.0.5 // indirect
github.com/libp2p/go-libp2p-net v0.0.2
github.com/libp2p/go-libp2p-peer v0.1.1
github.com/libp2p/go-libp2p-protocol v0.0.1
github.com/libp2p/go-libp2p-swarm v0.0.6
github.com/libp2p/go-libp2p-yamux v0.1.3 // indirect
github.com/libp2p/go-mplex v0.0.4 // indirect
github.com/libp2p/go-yamux v1.2.3 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/libp2p/go-libp2p-blankhost v0.1.1
github.com/libp2p/go-libp2p-core v0.0.1
github.com/libp2p/go-libp2p-swarm v0.1.0
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-dns v0.0.2 // indirect
github.com/multiformats/go-multistream v0.0.4
github.com/multiformats/go-multistream v0.1.0
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
156 changes: 62 additions & 94 deletions go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion gossipsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

host "github.com/libp2p/go-libp2p-host"
"github.com/libp2p/go-libp2p-core/host"
)

func getGossipsubs(ctx context.Context, hs []host.Host, opts ...Option) []*PubSub {
Expand Down
16 changes: 8 additions & 8 deletions notify.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package pubsub

import (
inet "github.com/libp2p/go-libp2p-net"
"github.com/libp2p/go-libp2p-core/network"
ma "github.com/multiformats/go-multiaddr"
)

var _ inet.Notifiee = (*PubSubNotif)(nil)
var _ network.Notifiee = (*PubSubNotif)(nil)

type PubSubNotif PubSub

func (p *PubSubNotif) OpenedStream(n inet.Network, s inet.Stream) {
func (p *PubSubNotif) OpenedStream(n network.Network, s network.Stream) {
}

func (p *PubSubNotif) ClosedStream(n inet.Network, s inet.Stream) {
func (p *PubSubNotif) ClosedStream(n network.Network, s network.Stream) {
}

func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn) {
func (p *PubSubNotif) Connected(n network.Network, c network.Conn) {
go func() {
select {
case p.newPeers <- c.RemotePeer():
Expand All @@ -24,11 +24,11 @@ func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn) {
}()
}

func (p *PubSubNotif) Disconnected(n inet.Network, c inet.Conn) {
func (p *PubSubNotif) Disconnected(n network.Network, c network.Conn) {
}

func (p *PubSubNotif) Listen(n inet.Network, _ ma.Multiaddr) {
func (p *PubSubNotif) Listen(n network.Network, _ ma.Multiaddr) {
}

func (p *PubSubNotif) ListenClose(n inet.Network, _ ma.Multiaddr) {
func (p *PubSubNotif) ListenClose(n network.Network, _ ma.Multiaddr) {
}
17 changes: 9 additions & 8 deletions pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

"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/protocol"

logging "github.com/ipfs/go-log"
crypto "github.com/libp2p/go-libp2p-crypto"
host "github.com/libp2p/go-libp2p-host"
inet "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
timecache "github.com/whyrusleeping/timecache"
)

Expand Down Expand Up @@ -63,7 +64,7 @@ type PubSub struct {
newPeers chan peer.ID

// a notification channel for new outoging peer streams
newPeerStream chan inet.Stream
newPeerStream chan network.Stream

// a notification channel for errors opening new peer streams
newPeerError chan peer.ID
Expand Down Expand Up @@ -162,7 +163,7 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option
incoming: make(chan *RPC, 32),
publish: make(chan *Message),
newPeers: make(chan peer.ID),
newPeerStream: make(chan inet.Stream),
newPeerStream: make(chan network.Stream),
newPeerError: make(chan peer.ID),
peerDead: make(chan peer.ID),
cancelCh: make(chan *Subscription),
Expand Down Expand Up @@ -320,7 +321,7 @@ func (p *PubSub) processLoop(ctx context.Context) {

close(ch)

if p.host.Network().Connectedness(pid) == inet.Connected {
if p.host.Network().Connectedness(pid) == network.Connected {
// still connected, must be a duplicate connection being closed.
// we respawn the writer as we need to ensure there is a stream active
log.Warning("peer declared dead but still connected; respawning writer: ", pid)
Expand Down
6 changes: 3 additions & 3 deletions randomsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

host "github.com/libp2p/go-libp2p-host"
peer "github.com/libp2p/go-libp2p-peer"
protocol "github.com/libp2p/go-libp2p-protocol"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/protocol"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

crypto "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
)

const SignPrefix = "libp2p-pubsub:"
Expand Down
4 changes: 2 additions & 2 deletions sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

crypto "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
)

func TestSigning(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"time"

peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-core/peer"
)

const (
Expand Down

0 comments on commit 49274b0

Please sign in to comment.