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-core
Commits
8ca20a2d
Commit
8ca20a2d
authored
Sep 13, 2019
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable network to emit events on a bus
parent
bcf3ad5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
network/events.go
network/events.go
+15
-0
network/network.go
network/network.go
+6
-0
No files found.
network/events.go
0 → 100644
View file @
8ca20a2d
package
network
// EvtPeerConnectionStateChange should be emitted when we connect/disconnect from a peer
type
EvtPeerConnectionStateChange
struct
{
Network
Network
Connection
Conn
NewState
Connectedness
}
// EvtStreamStateChange is emitted when we open/close a stream with a peer
type
EvtStreamStateChange
struct
{
Network
Network
Stream
Stream
NewState
Connectedness
}
network/network.go
View file @
8ca20a2d
...
...
@@ -10,6 +10,7 @@ import (
"io"
"github.com/jbenet/goprocess"
"github.com/libp2p/go-libp2p-core/event"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
...
...
@@ -100,6 +101,11 @@ type Network interface {
// Process returns the network's Process
Process
()
goprocess
.
Process
// EventBus returns the network's Event Bus
// we can subscribe to this bus to listen for connection/disconnection of peers,
// opening/closing of streams etc etc
EventBus
()
event
.
Bus
}
// Dialer represents a service that can dial out to peers
...
...
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