|
|
@ -5,10 +5,7 @@ use crate::{
|
|
|
|
database::Database,
|
|
|
|
database::Database,
|
|
|
|
execution_params::ExecutionParams,
|
|
|
|
execution_params::ExecutionParams,
|
|
|
|
monero, network,
|
|
|
|
monero, network,
|
|
|
|
network::{
|
|
|
|
network::peer_tracker::{self, PeerTracker},
|
|
|
|
peer_tracker::{self, PeerTracker},
|
|
|
|
|
|
|
|
transport::build,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
protocol::{alice, alice::TransferProof, bob},
|
|
|
|
protocol::{alice, alice::TransferProof, bob},
|
|
|
|
seed::Seed,
|
|
|
|
seed::Seed,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -53,7 +50,6 @@ pub struct Swap {
|
|
|
|
pub struct Builder {
|
|
|
|
pub struct Builder {
|
|
|
|
swap_id: Uuid,
|
|
|
|
swap_id: Uuid,
|
|
|
|
identity: Keypair,
|
|
|
|
identity: Keypair,
|
|
|
|
peer_id: PeerId,
|
|
|
|
|
|
|
|
db: Database,
|
|
|
|
db: Database,
|
|
|
|
|
|
|
|
|
|
|
|
alice_address: Multiaddr,
|
|
|
|
alice_address: Multiaddr,
|
|
|
@ -84,12 +80,10 @@ impl Builder {
|
|
|
|
execution_params: ExecutionParams,
|
|
|
|
execution_params: ExecutionParams,
|
|
|
|
) -> Self {
|
|
|
|
) -> Self {
|
|
|
|
let identity = network::Seed::new(seed).derive_libp2p_identity();
|
|
|
|
let identity = network::Seed::new(seed).derive_libp2p_identity();
|
|
|
|
let peer_id = identity.public().into_peer_id();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Self {
|
|
|
|
Self {
|
|
|
|
swap_id,
|
|
|
|
swap_id,
|
|
|
|
identity,
|
|
|
|
identity,
|
|
|
|
peer_id,
|
|
|
|
|
|
|
|
db,
|
|
|
|
db,
|
|
|
|
alice_address,
|
|
|
|
alice_address,
|
|
|
|
alice_peer_id,
|
|
|
|
alice_peer_id,
|
|
|
@ -152,13 +146,8 @@ impl Builder {
|
|
|
|
fn init_event_loop(
|
|
|
|
fn init_event_loop(
|
|
|
|
&self,
|
|
|
|
&self,
|
|
|
|
) -> Result<(bob::event_loop::EventLoop, bob::event_loop::EventLoopHandle)> {
|
|
|
|
) -> Result<(bob::event_loop::EventLoop, bob::event_loop::EventLoopHandle)> {
|
|
|
|
let bob_behaviour = bob::Behaviour::default();
|
|
|
|
|
|
|
|
let bob_transport = build(&self.identity)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bob::event_loop::EventLoop::new(
|
|
|
|
bob::event_loop::EventLoop::new(
|
|
|
|
bob_transport,
|
|
|
|
&self.identity,
|
|
|
|
bob_behaviour,
|
|
|
|
|
|
|
|
self.peer_id,
|
|
|
|
|
|
|
|
self.alice_peer_id,
|
|
|
|
self.alice_peer_id,
|
|
|
|
self.alice_address.clone(),
|
|
|
|
self.alice_address.clone(),
|
|
|
|
self.bitcoin_wallet.clone(),
|
|
|
|
self.bitcoin_wallet.clone(),
|
|
|
|