|
|
@ -1,7 +1,7 @@
|
|
|
|
use crate::{
|
|
|
|
use crate::{
|
|
|
|
bitcoin,
|
|
|
|
bitcoin,
|
|
|
|
bitcoin::EncryptedSignature,
|
|
|
|
bitcoin::EncryptedSignature,
|
|
|
|
network::{transport::SwapTransport, TokioExecutor},
|
|
|
|
network::{transport, TokioExecutor},
|
|
|
|
protocol::{
|
|
|
|
protocol::{
|
|
|
|
alice::{QuoteResponse, TransferProof},
|
|
|
|
alice::{QuoteResponse, TransferProof},
|
|
|
|
bob::{Behaviour, OutEvent, QuoteRequest, State0, State2},
|
|
|
|
bob::{Behaviour, OutEvent, QuoteRequest, State0, State2},
|
|
|
@ -114,18 +114,23 @@ pub struct EventLoop {
|
|
|
|
|
|
|
|
|
|
|
|
impl EventLoop {
|
|
|
|
impl EventLoop {
|
|
|
|
pub fn new(
|
|
|
|
pub fn new(
|
|
|
|
transport: SwapTransport,
|
|
|
|
identity: &libp2p::core::identity::Keypair,
|
|
|
|
behaviour: Behaviour,
|
|
|
|
|
|
|
|
peer_id: PeerId,
|
|
|
|
|
|
|
|
alice_peer_id: PeerId,
|
|
|
|
alice_peer_id: PeerId,
|
|
|
|
alice_addr: Multiaddr,
|
|
|
|
alice_addr: Multiaddr,
|
|
|
|
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
|
|
|
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
|
|
|
) -> Result<(Self, EventLoopHandle)> {
|
|
|
|
) -> Result<(Self, EventLoopHandle)> {
|
|
|
|
let mut swarm = libp2p::swarm::SwarmBuilder::new(transport, behaviour, peer_id)
|
|
|
|
let behaviour = Behaviour::default();
|
|
|
|
.executor(Box::new(TokioExecutor {
|
|
|
|
let transport = transport::build(identity)?;
|
|
|
|
handle: tokio::runtime::Handle::current(),
|
|
|
|
|
|
|
|
}))
|
|
|
|
let mut swarm = libp2p::swarm::SwarmBuilder::new(
|
|
|
|
.build();
|
|
|
|
transport,
|
|
|
|
|
|
|
|
behaviour,
|
|
|
|
|
|
|
|
identity.public().into_peer_id(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.executor(Box::new(TokioExecutor {
|
|
|
|
|
|
|
|
handle: tokio::runtime::Handle::current(),
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
swarm.add_address(alice_peer_id, alice_addr);
|
|
|
|
swarm.add_address(alice_peer_id, alice_addr);
|
|
|
|
|
|
|
|
|
|
|
|