From 8721a124d26eba3db55d8497b42ecaa399ec7d6d Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Sat, 29 Feb 2020 11:46:17 +0530 Subject: [PATCH] peer connectedness event --- event/network.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/event/network.go b/event/network.go index 8fcc1ea..c03c8d9 100644 --- a/event/network.go +++ b/event/network.go @@ -2,18 +2,13 @@ package event import "github.com/libp2p/go-libp2p-core/network" -// EvtPeerConnectionStateChange should be emitted when we connect to a peer or disconnect -// from a peer. It contains the network interface for the connection, -// the connection handle & the new state of the connection. -type EvtPeerConnectionStateChange struct { +// EvtPeerStateChange should be emitted when we form our first connection with a peer or drop our last +// connection with the peer. Essentially, it is emitted in two cases: +// a) We go from having no connection with a peer to having a connection with a peer. +// b) We go from having a connection/s with a peer to having no connection with the peer. +// It contains the network interface for the connection, the connection handle for the first/last connection and +// the new connection state. +type EvtPeerStateChange struct { Connection network.Conn NewState network.Connectedness } - -// EvtStreamStateChange should be emitted when we open a new stream with a peer or close an existing stream. -// It contains the network interface for the connection, the stream handle & -// the new state of the stream. -type EvtStreamStateChange struct { - Stream network.Stream - NewState network.Connectedness -}