Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/refactor comms actor #91

Merged
merged 2 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changes/2020-12-21T-communication_actor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"stronghold-communication": minor
---
Refactor the communication actor by adding config and implementing a seperate struct for the swarm task.
12 changes: 5 additions & 7 deletions communication/examples/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libp2p::core::identity::Keypair;
use riker::actors::*;
use serde::{Deserialize, Serialize};
use stronghold_communication::{
actor::{CommunicationActor, CommunicationEvent},
actor::{CommsActorConfig, CommunicationActor, CommunicationEvent},
behaviour::message::P2PReqResEvent,
};

Expand Down Expand Up @@ -64,14 +64,12 @@ impl Actor for TestActor {
}

fn main() {
let local_keys = Keypair::generate_ed25519();
let sys = ActorSystem::new().unwrap();
let local_keys = Keypair::generate_ed25519();
let chan: ChannelRef<CommunicationEvent<Request, Response>> = channel("p2p", &sys).unwrap();
sys.actor_of_args::<CommunicationActor<Request, Response>, _>(
"communication-actor",
(local_keys, chan.clone(), None),
)
.unwrap();
let config = CommsActorConfig::new(local_keys, None, Some(chan.clone()), None);
sys.actor_of_args::<CommunicationActor<Request, Response>, _>("communication-actor", config)
.unwrap();
sys.actor_of_args::<TestActor, _>("test-actor", chan).unwrap();
std::thread::sleep(Duration::from_secs(600));
}
Loading