Skip to content

Commit

Permalink
fix: check limits first before other behaviours (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc authored Nov 14, 2023
1 parent 7e2d3f4 commit 071cd48
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion p2p/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ pub const AGENT_VERSION: &str = concat!("ceramic-one/", env!("CARGO_PKG_VERSION"
#[derive(NetworkBehaviour)]
#[behaviour(to_swarm = "Event")]
pub(crate) struct NodeBehaviour<I, M> {
// Place limits first in the behaviour tree.
// Behaviours are called in order and the limits behaviour can deny connections etc.
// It keeps things simpler in other behaviours if they are never called for connections that
// end up being denied because of the limits.
// See https://github.com/libp2p/rust-libp2p/pull/4777#discussion_r1391833734 for more context.
limits: connection_limits::Behaviour,
ping: Ping,
identify: identify::Behaviour,
pub(crate) bitswap: Toggle<Bitswap<SQLiteBlockStore>>,
Expand All @@ -53,7 +59,6 @@ pub(crate) struct NodeBehaviour<I, M> {
dcutr: Toggle<dcutr::Behaviour>,
pub(crate) gossipsub: Toggle<gossipsub::Behaviour>,
pub(crate) peer_manager: PeerManager,
limits: connection_limits::Behaviour,
recon: Toggle<recon::libp2p::Behaviour<I, M>>,
}

Expand Down

0 comments on commit 071cd48

Please sign in to comment.