Drive swarm in seperate async task

Previously the libp2p swarm had to be manually polled within the
protocol execution code to execute actions such as sending a
message. The swarm is now wrapped in SwarmDriver which polls the
swarm in a seperate task
This commit is contained in:
rishflab 2020-12-07 13:31:14 +11:00
parent f88ed9183b
commit 6f7408ecce
10 changed files with 366 additions and 128 deletions

View file

@ -43,6 +43,7 @@ mod message1;
mod message2;
mod message3;
pub mod swap;
pub mod swarm_driver;
pub async fn swap(
bitcoin_wallet: Arc<bitcoin::Wallet>,
@ -117,7 +118,7 @@ pub async fn swap(
OutEvent::ConnectionEstablished(bob) => {
info!("Connection established with: {}", bob);
}
OutEvent::Request(amounts::OutEvent::Btc { btc, channel }) => {
OutEvent::Request(amounts::OutEvent { btc, channel }) => {
let amounts = calculate_amounts(btc);
last_amounts = Some(amounts);
swarm.send_amounts(channel, amounts);