From 31c63f0c4de954e90a2a0b5ac7ac81d5e68d8c62 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 14 Jan 2021 11:35:10 +1100 Subject: [PATCH] Remove dead code --- swap/src/bitcoin/transactions.rs | 4 ---- swap/src/bitcoin/wallet.rs | 2 -- swap/src/lib.rs | 3 +-- swap/src/main.rs | 4 +++- swap/src/monero.rs | 6 ------ swap/src/network/transport.rs | 35 -------------------------------- 6 files changed, 4 insertions(+), 50 deletions(-) diff --git a/swap/src/bitcoin/transactions.rs b/swap/src/bitcoin/transactions.rs index f5242813..d8d2c059 100644 --- a/swap/src/bitcoin/transactions.rs +++ b/swap/src/bitcoin/transactions.rs @@ -469,10 +469,6 @@ impl TxPunish { } } - pub fn txid(&self) -> Txid { - self.inner.txid() - } - pub fn digest(&self) -> SigHash { self.digest } diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 0582f84e..6cbc777b 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -16,8 +16,6 @@ use crate::{ config::Config, }; -pub const TX_LOCK_MINE_TIMEOUT: u64 = 3600; - #[derive(Debug)] pub struct Wallet { pub inner: bitcoin_harness::Wallet, diff --git a/swap/src/lib.rs b/swap/src/lib.rs index c33479a7..f7020277 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -20,10 +20,9 @@ use serde::{Deserialize, Serialize}; use std::fmt::{self, Display}; pub mod bitcoin; -pub mod cli; pub mod config; pub mod database; -pub mod fs; +mod fs; pub mod monero; pub mod network; pub mod protocol; diff --git a/swap/src/main.rs b/swap/src/main.rs index ece38ff7..5ef84e7a 100644 --- a/swap/src/main.rs +++ b/swap/src/main.rs @@ -13,6 +13,7 @@ #![forbid(unsafe_code)] #![allow(non_snake_case)] +use crate::cli::{Command, Options, Resume}; use anyhow::{bail, Context, Result}; use libp2p::{core::Multiaddr, PeerId}; use prettytable::{row, Table}; @@ -21,7 +22,6 @@ use std::sync::Arc; use structopt::StructOpt; use swap::{ bitcoin, - cli::{Command, Options, Resume}, config::Config, database::{Database, Swap}, monero, network, @@ -34,6 +34,8 @@ use swap::{ use tracing::{info, log::LevelFilter}; use uuid::Uuid; +mod cli; + #[macro_use] extern crate prettytable; diff --git a/swap/src/monero.rs b/swap/src/monero.rs index 3c177884..499e248d 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -23,12 +23,6 @@ pub use wallet::Wallet; pub const PICONERO_OFFSET: u64 = 1_000_000_000_000; -pub fn random_private_key(rng: &mut R) -> PrivateKey { - let scalar = Scalar::random(rng); - - PrivateKey::from_scalar(scalar) -} - pub fn private_key_from_secp256k1_scalar(scalar: bitcoin::Scalar) -> PrivateKey { let mut bytes = scalar.to_bytes(); diff --git a/swap/src/network/transport.rs b/swap/src/network/transport.rs index 5fa715fa..eb025f20 100644 --- a/swap/src/network/transport.rs +++ b/swap/src/network/transport.rs @@ -39,40 +39,5 @@ pub fn build(id_keys: identity::Keypair) -> Result { Ok(transport) } -/// Builds a libp2p transport with Tor and with the following features: -/// - TCP connection over the Tor network -/// - DNS name resolution -/// - authentication via noise -/// - multiplexing via yamux or mplex -pub fn build_tor( - id_keys: identity::Keypair, - address_port_pair: Option<(libp2p::core::Multiaddr, u16)>, -) -> Result { - use libp2p_tokio_socks5::Socks5TokioTcpConfig; - use std::collections::HashMap; - - let mut map = HashMap::new(); - if let Some((addr, port)) = address_port_pair { - map.insert(addr, port); - } - - let dh_keys = noise::Keypair::::new().into_authentic(&id_keys)?; - let noise = NoiseConfig::xx(dh_keys).into_authenticated(); - - let socks = Socks5TokioTcpConfig::default().nodelay(true).onion_map(map); - let dns = DnsConfig::new(socks)?; - - let transport = dns - .upgrade(Version::V1) - .authenticate(noise) - .multiplex(SelectUpgrade::new( - yamux::Config::default(), - MplexConfig::new(), - )) - .map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer))) - .boxed(); - - Ok(transport) -} pub type SwapTransport = Boxed<(PeerId, StreamMuxerBox)>;