You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The type of peer this handler is associated to.
peer_kind:Option<PeerKind>,
/// Keeps track on whether we have sent the peer kind to the behaviour.
//
// NOTE: Use this flag rather than checking the substream count each poll.
peer_kind_sent:bool,
/// If the peer doesn't support the gossipsub protocol we do not immediately disconnect.
/// Rather, we disable the handler and prevent any incoming or outgoing substreams from being
/// established.
///
/// This value is set to true to indicate the peer doesn't support gossipsub.
protocol_unsupported:bool,
We can simplify this by narrowing down the possible state combinations. For example, currently the type system allows peer_kind to be Some and peer_kind_sent to be true which is not possible.
Something similar can likely be done with the current outbound stream and the outbound_substream_establishing flag. It could be an enum:
enumOutboundStream{Establishing,Some(S),None}
Motivation
Less complexity in understanding the possible states of the handler
Use the type system to our advantage
Current Implementation
Are you planning to do it yourself in a pull request?
No.
The text was updated successfully, but these errors were encountered:
looking to engage with libp2p, and would love to contribute to it or other beginner-friendly , If provided some help and pointers. Just wanted to ask if you are open for contribution as there is no Contribution.md
looking to engage with libp2p, and would love to contribute to it or other beginner-friendly , If provided some help and pointers. Just wanted to ask if you are open for contribution as there is no Contribution.md
Definitely open to contributions, thank you!
Check out the issues labelled with getting-started and one that matches the difficulty you are after.
Writing a contribution guide is ironically also an open task: #3743
Description
Currently, we use a combination of booleans and enums to represent how the remote peer supports gossipsub:
rust-libp2p/protocols/gossipsub/src/handler.rs
Lines 109 to 122 in 0e46865
We can simplify this by narrowing down the possible state combinations. For example, currently the type system allows
peer_kind
to beSome
andpeer_kind_sent
to betrue
which is not possible.Something similar can likely be done with the current outbound stream and the
outbound_substream_establishing
flag. It could be an enum:Motivation
Current Implementation
Are you planning to do it yourself in a pull request?
No.
The text was updated successfully, but these errors were encountered: