Skip to content

Commit

Permalink
Rename DialerActor to Dialer
Browse files Browse the repository at this point in the history
  • Loading branch information
hmzakhalid committed Jan 6, 2025
1 parent 4ceda49 commit 05dee3b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions packages/ciphernode/events/src/enclave_event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,18 @@ impl EnclaveEvent {
_ => false,
}
}

pub fn event_type(&self) -> String {
let s = format!("{:?}", self);
extract_enclave_event_name(&s).to_string()
}
}

impl Event for EnclaveEvent {
type Id = EventId;

fn event_type(&self) -> String {
let s = format!("{:?}", self);
extract_enclave_event_name(&s).to_string()
self.event_type()
}

fn event_id(&self) -> Self::Id {
Expand Down
4 changes: 2 additions & 2 deletions packages/ciphernode/net/src/bin/p2p_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use events::{EventBus, EventBusConfig, GetHistory};
use libp2p::gossipsub;
use net::correlation_id::CorrelationId;
use net::events::{NetworkPeerCommand, NetworkPeerEvent};
use net::DialerActor;
use net::Dialer;
use net::NetworkPeer;
use std::time::Duration;
use std::{collections::HashSet, env, process};
Expand Down Expand Up @@ -72,7 +72,7 @@ async fn main() -> Result<()> {

// Set up dialer for peers
for peer in peers {
DialerActor::dial_peer(peer, net_bus.clone(), tx.clone());
Dialer::dial_peer(peer, net_bus.clone(), tx.clone());
}

// Send our message first
Expand Down
10 changes: 5 additions & 5 deletions packages/ciphernode/net/src/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ struct PendingConnection {
}

#[derive(Clone)]
pub struct DialerActor {
pub struct Dialer {
net_bus: Addr<EventBus<NetworkPeerEvent>>,
tx: mpsc::Sender<NetworkPeerCommand>,
pending_connection: HashMap<ConnectionId, PendingConnection>,
}

impl DialerActor {
impl Dialer {
pub fn new(
net_bus: Addr<EventBus<NetworkPeerEvent>>,
tx: mpsc::Sender<NetworkPeerCommand>,
Expand Down Expand Up @@ -169,11 +169,11 @@ impl DialerActor {
}
}

impl Actor for DialerActor {
impl Actor for Dialer {
type Context = Context<Self>;
}

impl Handler<NetworkPeerEvent> for DialerActor {
impl Handler<NetworkPeerEvent> for Dialer {
type Result = ();

fn handle(&mut self, msg: NetworkPeerEvent, ctx: &mut Context<Self>) {
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Handler<NetworkPeerEvent> for DialerActor {
}
}

impl Handler<DialPeer> for DialerActor {
impl Handler<DialPeer> for Dialer {
type Result = Result<()>;

fn handle(&mut self, msg: DialPeer, ctx: &mut Context<Self>) -> Self::Result {
Expand Down
4 changes: 2 additions & 2 deletions packages/ciphernode/net/src/network_manager.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::correlation_id::CorrelationId;
use crate::dialer::DialerActor;
use crate::dialer::Dialer;
use crate::events::{NetworkPeerCommand, NetworkPeerEvent};
use crate::network_peer::NetworkPeer;

Expand Down Expand Up @@ -114,7 +114,7 @@ impl NetworkManager {

let handle = tokio::spawn(async move { Ok(swarm_manager.start().await?) });
for peer in peers {
DialerActor::dial_peer(peer, net_bus.clone(), tx.clone());
Dialer::dial_peer(peer, net_bus.clone(), tx.clone());
}

let p2p_addr = NetworkManager::setup(bus, net_bus, tx, &topic.to_string());
Expand Down

0 comments on commit 05dee3b

Please sign in to comment.