Skip to content

Commit

Permalink
protocols/dcutr: Rename Action to ActionBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Feb 2, 2022
1 parent b50708b commit f18a863
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions protocols/dcutr/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum UpgradeError {

pub struct Behaviour {
/// Queue of actions to return when polled.
queued_actions: VecDeque<Action>,
queued_actions: VecDeque<ActionBuilder>,

/// All direct (non-relayed) connections.
direct_connections: HashMap<PeerId, HashSet<ConnectionId>>,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl NetworkBehaviour for Behaviour {
//
// https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol
self.queued_actions.extend([
Action::Connect {
ActionBuilder::Connect {
peer_id: *peer_id,
attempt: 1,
handler: NotifyHandler::One(*connection_id),
Expand Down Expand Up @@ -152,7 +152,7 @@ impl NetworkBehaviour for Behaviour {
let peer_id =
peer_id.expect("Peer of `Prototype::DirectConnection` is always known.");
if attempt < MAX_NUMBER_OF_UPGRADE_ATTEMPTS {
self.queued_actions.push_back(Action::Connect {
self.queued_actions.push_back(ActionBuilder::Connect {
peer_id,
handler: NotifyHandler::One(relayed_connection_id),
attempt: attempt + 1,
Expand Down Expand Up @@ -219,7 +219,7 @@ impl NetworkBehaviour for Behaviour {
remote_addr,
}) => {
self.queued_actions.extend([
Action::AcceptInboundConnect {
ActionBuilder::AcceptInboundConnect {
peer_id: event_source,
handler: NotifyHandler::One(connection),
inbound_connect,
Expand Down Expand Up @@ -327,7 +327,7 @@ impl NetworkBehaviour for Behaviour {
/// A [`NetworkBehaviourAction`], either complete, or still requiring data from [`PollParameters`]
/// before being returned in [`Behaviour::poll`].
#[allow(clippy::large_enum_variant)]
enum Action {
enum ActionBuilder {
Done(NetworkBehaviourAction<Event, handler::Prototype>),
Connect {
attempt: u8,
Expand All @@ -341,13 +341,13 @@ enum Action {
},
}

impl From<NetworkBehaviourAction<Event, handler::Prototype>> for Action {
impl From<NetworkBehaviourAction<Event, handler::Prototype>> for ActionBuilder {
fn from(action: NetworkBehaviourAction<Event, handler::Prototype>) -> Self {
Self::Done(action)
}
}

impl Action {
impl ActionBuilder {
fn build(
self,
poll_parameters: &mut impl PollParameters,
Expand All @@ -364,8 +364,8 @@ impl Action {
};

match self {
Action::Done(action) => action,
Action::AcceptInboundConnect {
ActionBuilder::Done(action) => action,
ActionBuilder::AcceptInboundConnect {
inbound_connect,
handler,
peer_id,
Expand All @@ -377,7 +377,7 @@ impl Action {
obs_addrs: obs_addrs(),
}),
},
Action::Connect {
ActionBuilder::Connect {
attempt,
handler,
peer_id,
Expand Down

0 comments on commit f18a863

Please sign in to comment.