Skip to content

Commit

Permalink
handling termination
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Apr 14, 2024
1 parent c137a9d commit 9d7f3cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crates/delegator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// 2. Generate topic
let topic = gossipsub_ident_topic(Network::Sepolia, Topic::NewJob);

let swarm_runner = SwarmRunner::new(&p2p_local_keypair, &topic)?;
let mut swarm_runner = SwarmRunner::new(&p2p_local_keypair, &topic)?;
let mut registry_handler = RegistryHandler::new(
"https://starknet-sepolia.public.blastapi.io",
"0xcdd51fbc4e008f4ef807eaf26f5043521ef5931bbb1e04032a25bd845d286b",
Expand All @@ -36,6 +36,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
Some(Ok(event_vec)) = event_stream.next() => {
debug!("{:?}", event_vec);
},
else => break
}
}

Ok(())
}
5 changes: 4 additions & 1 deletion crates/executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// 2. Generate topic
let topic = gossipsub_ident_topic(Network::Sepolia, Topic::PickedJob);

let swarm_runner = SwarmRunner::new(&p2p_local_keypair, &topic)?;
let mut swarm_runner = SwarmRunner::new(&p2p_local_keypair, &topic)?;
let mut registry_handler = RegistryHandler::new(
"https://starknet-sepolia.public.blastapi.io",
"0xcdd51fbc4e008f4ef807eaf26f5043521ef5931bbb1e04032a25bd845d286b",
Expand All @@ -36,6 +36,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
Some(Ok(event_vec)) = event_stream.next() => {
debug!("{:?}", event_vec);
},
else => break
}
}

Ok(())
}
7 changes: 4 additions & 3 deletions crates/peer/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ impl SwarmRunner {
}

pub fn run(
mut self,
&mut self,
send_topic: IdentTopic,
mut send_topic_rx: mpsc::Receiver<Vec<u8>>,
) -> Pin<Box<impl Stream<Item = gossipsub::Event>>> {
) -> Pin<Box<impl Stream<Item = gossipsub::Event> + '_>> {
let stream = stream! {
loop {
tokio::select! {
Expand Down Expand Up @@ -105,7 +105,8 @@ impl SwarmRunner {
debug!("Local node is listening on {address}");
}
_ => {}
}
},
else => break
}
}
};
Expand Down

0 comments on commit 9d7f3cb

Please sign in to comment.