go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

revisit the PeerConnectedness event

Open marten-seemann opened this issue 3 years ago • 2 comments

We're currently defining 4 different states for the Connectedness: https://pkg.go.dev/github.com/libp2p/[email protected]/network#Connectedness, of which we're only using NotConnected and Connected.

This is confusing to users of the library, we shouldn't define states that we're not actually using.

Furthermore, we should introduce a ConnectedViaTransientConnection state, and emit that instead of Connected when we establish a transient (i.e. a connection via a relay), and emit another Connected event once we transition from a transient to a direct connection.

This came up in https://github.com/libp2p/go-libp2p/pull/1562.

cc @MarcoPolo @Stebalien

marten-seemann avatar May 27 '22 18:05 marten-seemann

Yup, agreed. Although it would be nice to actually implement CannotConnect.

Stebalien avatar May 27 '22 23:05 Stebalien

Agreed. From the user's perspective it's better to not define that constant, than to define it and then not to emit it. Let's make it a TODO.

marten-seemann avatar May 28 '22 08:05 marten-seemann