generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
161 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use actix::{Actor, Addr, Context, Handler}; | ||
|
||
use crate::{EnclaveEvent, EventBus, Subscribe}; | ||
|
||
pub struct SimpleLogger; | ||
|
||
impl SimpleLogger { | ||
pub fn attach(bus:Addr<EventBus>) -> Addr<Self>{ | ||
let addr = Self.start(); | ||
bus.do_send(Subscribe { | ||
listener:addr.clone().recipient(), | ||
event_type: "*".to_string() | ||
}); | ||
addr | ||
} | ||
} | ||
|
||
impl Actor for SimpleLogger { | ||
type Context = Context<Self>; | ||
} | ||
|
||
impl Handler<EnclaveEvent> for SimpleLogger { | ||
type Result = (); | ||
fn handle(&mut self, msg: EnclaveEvent, _: &mut Self::Context) -> Self::Result { | ||
println!("{}", msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::error::Error; | ||
|
||
use enclave_core::Actor; | ||
use enclave_core::ComputationRequested; | ||
use enclave_core::E3id; | ||
use enclave_core::EnclaveEvent; | ||
use enclave_core::EventBus; | ||
use enclave_core::P2p; | ||
use tokio::{ | ||
self, | ||
io::{self, AsyncBufReadExt, BufReader}, | ||
}; | ||
|
||
#[actix_rt::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let bus = EventBus::new(true).start(); | ||
let (_, t1) = P2p::spawn_libp2p(bus.clone())?; | ||
let mut stdin = BufReader::new(io::stdin()).lines(); | ||
let t2 = tokio::spawn(async move { | ||
let mut id: u32 = 1000; | ||
while let Ok(Some(line)) = stdin.next_line().await { | ||
match line.as_str() { | ||
"test" => { | ||
id += 1; | ||
bus.do_send(EnclaveEvent::from(ComputationRequested { | ||
e3_id: E3id::from(id), | ||
nodecount: 3, | ||
threshold: 3, | ||
sortition_seed: 100, | ||
})); | ||
} | ||
_ => println!("Unknown command"), | ||
} | ||
} | ||
}); | ||
|
||
let _ = tokio::join!(t1, t2); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters