Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-pubsub
Commits
49274b0e
Unverified
Commit
49274b0e
authored
May 26, 2019
by
Raúl Kripalani
Committed by
GitHub
May 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate to consolidated types. (#185)
parent
08ddcf7b
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
113 additions
and
155 deletions
+113
-155
blacklist.go
blacklist.go
+1
-1
blacklist_test.go
blacklist_test.go
+1
-1
comm.go
comm.go
+9
-7
floodsub.go
floodsub.go
+3
-3
floodsub_test.go
floodsub_test.go
+4
-3
go.mod
go.mod
+4
-18
go.sum
go.sum
+62
-94
gossipsub.go
gossipsub.go
+3
-3
gossipsub_test.go
gossipsub_test.go
+1
-1
notify.go
notify.go
+8
-8
pubsub.go
pubsub.go
+9
-8
randomsub.go
randomsub.go
+3
-3
sign.go
sign.go
+2
-2
sign_test.go
sign_test.go
+2
-2
validation.go
validation.go
+1
-1
No files found.
blacklist.go
View file @
49274b0e
...
...
@@ -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.
...
...
blacklist_test.go
View file @
49274b0e
...
...
@@ -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
)
{
...
...
comm.go
View file @
49274b0e
...
...
@@ -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"
)
...
...
@@ -27,7 +29,7 @@ func (p *PubSub) getHelloPacket() *RPC {
return
&
rpc
}
func
(
p
*
PubSub
)
handleNewStream
(
s
i
net
.
Stream
)
{
func
(
p
*
PubSub
)
handleNewStream
(
s
net
work
.
Stream
)
{
r
:=
ggio
.
NewDelimitedReader
(
s
,
1
<<
20
)
for
{
rpc
:=
new
(
RPC
)
...
...
@@ -82,7 +84,7 @@ func (p *PubSub) handleNewPeer(ctx context.Context, pid peer.ID, outgoing <-chan
}
}
func
(
p
*
PubSub
)
handlePeerEOF
(
ctx
context
.
Context
,
s
i
net
.
Stream
)
{
func
(
p
*
PubSub
)
handlePeerEOF
(
ctx
context
.
Context
,
s
net
work
.
Stream
)
{
r
:=
ggio
.
NewDelimitedReader
(
s
,
1
<<
20
)
rpc
:=
new
(
RPC
)
for
{
...
...
@@ -98,7 +100,7 @@ func (p *PubSub) handlePeerEOF(ctx context.Context, s inet.Stream) {
}
}
func
(
p
*
PubSub
)
handleSendingMessages
(
ctx
context
.
Context
,
s
i
net
.
Stream
,
outgoing
<-
chan
*
RPC
)
{
func
(
p
*
PubSub
)
handleSendingMessages
(
ctx
context
.
Context
,
s
net
work
.
Stream
,
outgoing
<-
chan
*
RPC
)
{
bufw
:=
bufio
.
NewWriter
(
s
)
wc
:=
ggio
.
NewDelimitedWriter
(
bufw
)
...
...
@@ -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
:
...
...
floodsub.go
View file @
49274b0e
...
...
@@ -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
(
...
...
floodsub_test.go
View file @
49274b0e
...
...
@@ -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"
)
...
...
go.mod
View file @
49274b0e
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
)
go.sum
View file @
49274b0e
This diff is collapsed.
Click to expand it.
gossipsub.go
View file @
49274b0e
...
...
@@ -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
(
...
...
gossipsub_test.go
View file @
49274b0e
...
...
@@ -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
{
...
...
notify.go
View file @
49274b0e
package
pubsub
import
(
inet
"github.com/libp2p/go-libp2p-
net
"
"github.com/libp2p/go-libp2p-
core/network
"
ma
"github.com/multiformats/go-multiaddr"
)
var
_
i
net
.
Notifiee
=
(
*
PubSubNotif
)(
nil
)
var
_
net
work
.
Notifiee
=
(
*
PubSubNotif
)(
nil
)
type
PubSubNotif
PubSub
func
(
p
*
PubSubNotif
)
OpenedStream
(
n
i
net
.
Network
,
s
i
net
.
Stream
)
{
func
(
p
*
PubSubNotif
)
OpenedStream
(
n
net
work
.
Network
,
s
net
work
.
Stream
)
{
}
func
(
p
*
PubSubNotif
)
ClosedStream
(
n
i
net
.
Network
,
s
i
net
.
Stream
)
{
func
(
p
*
PubSubNotif
)
ClosedStream
(
n
net
work
.
Network
,
s
net
work
.
Stream
)
{
}
func
(
p
*
PubSubNotif
)
Connected
(
n
i
net
.
Network
,
c
i
net
.
Conn
)
{
func
(
p
*
PubSubNotif
)
Connected
(
n
net
work
.
Network
,
c
net
work
.
Conn
)
{
go
func
()
{
select
{
case
p
.
newPeers
<-
c
.
RemotePeer
()
:
...
...
@@ -24,11 +24,11 @@ func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn) {
}()
}
func
(
p
*
PubSubNotif
)
Disconnected
(
n
i
net
.
Network
,
c
i
net
.
Conn
)
{
func
(
p
*
PubSubNotif
)
Disconnected
(
n
net
work
.
Network
,
c
net
work
.
Conn
)
{
}
func
(
p
*
PubSubNotif
)
Listen
(
n
i
net
.
Network
,
_
ma
.
Multiaddr
)
{
func
(
p
*
PubSubNotif
)
Listen
(
n
net
work
.
Network
,
_
ma
.
Multiaddr
)
{
}
func
(
p
*
PubSubNotif
)
ListenClose
(
n
i
net
.
Network
,
_
ma
.
Multiaddr
)
{
func
(
p
*
PubSubNotif
)
ListenClose
(
n
net
work
.
Network
,
_
ma
.
Multiaddr
)
{
}
pubsub.go
View file @
49274b0e
...
...
@@ -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"
)
...
...
@@ -63,7 +64,7 @@ type PubSub struct {
newPeers
chan
peer
.
ID
// a notification channel for new outoging peer streams
newPeerStream
chan
i
net
.
Stream
newPeerStream
chan
net
work
.
Stream
// a notification channel for errors opening new peer streams
newPeerError
chan
peer
.
ID
...
...
@@ -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
i
net
.
Stream
),
newPeerStream
:
make
(
chan
net
work
.
Stream
),
newPeerError
:
make
(
chan
peer
.
ID
),
peerDead
:
make
(
chan
peer
.
ID
),
cancelCh
:
make
(
chan
*
Subscription
),
...
...
@@ -320,7 +321,7 @@ func (p *PubSub) processLoop(ctx context.Context) {
close
(
ch
)
if
p
.
host
.
Network
()
.
Connectedness
(
pid
)
==
i
net
.
Connected
{
if
p
.
host
.
Network
()
.
Connectedness
(
pid
)
==
net
work
.
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
)
...
...
randomsub.go
View file @
49274b0e
...
...
@@ -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
(
...
...
sign.go
View file @
49274b0e
...
...
@@ -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:"
...
...
sign_test.go
View file @
49274b0e
...
...
@@ -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
)
{
...
...
validation.go
View file @
49274b0e
...
...
@@ -6,7 +6,7 @@ import (
"runtime"
"time"
peer
"github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-
core/
peer"
)
const
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment