Skip to content

Commit

Permalink
take TakerConfig from struct instead of having parameter for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
15IITian committed Sep 7, 2024
1 parent 57bf238 commit 00388c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
11 changes: 1 addition & 10 deletions src/bin/taker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,7 @@ fn main() {
println!("{:?}", address);
}
Commands::SyncOfferBook => {
let taker2 = Taker::init(
args.data_directory,
Some(args.wallet_name),
Some(rpc_config),
TakerBehavior::Normal,
Some(connection_type),
)
.unwrap();
let config = taker2.config.clone();
taker.sync_offerbook(&config, args.maker_count).unwrap();
taker.sync_offerbook(args.maker_count).unwrap();
}
Commands::DoCoinswap => {
taker.do_coinswap(swap_params).unwrap();
Expand Down
18 changes: 6 additions & 12 deletions src/taker/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ impl Taker {
/// If that fails too. Open an issue at [our github](https://github.com/citadel-tech/coinswap/issues)
pub fn send_coinswap(&mut self, swap_params: SwapParams) -> Result<(), TakerError> {
log::info!("Syncing Offerbook");
let config = self.config.clone();
self.sync_offerbook(&config, swap_params.maker_count)?;

self.sync_offerbook(swap_params.maker_count)?;
// Generate new random preimage and initiate the first hop.
let mut preimage = [0u8; 32];
OsRng.fill_bytes(&mut preimage);
Expand Down Expand Up @@ -1909,21 +1907,17 @@ impl Taker {
}

/// Synchronizes the offer book with addresses obtained from directory servers and local configurations.
pub fn sync_offerbook(
&mut self,
config: &TakerConfig,
maker_count: usize,
) -> Result<(), TakerError> {
pub fn sync_offerbook(&mut self, maker_count: usize) -> Result<(), TakerError> {
let directory_address = match self.config.connection_type {
ConnectionType::CLEARNET => {
let mut address = config.directory_server_clearnet_address.clone();
let mut address = self.config.directory_server_clearnet_address.clone();
if cfg!(feature = "integration-test") {
address = format!("127.0.0.1:{}", 8080);
}
address
}
ConnectionType::TOR => {
let mut address = config.directory_server_onion_address.clone();
let mut address = self.config.directory_server_onion_address.clone();
if cfg!(feature = "integration-test") {
let directory_hs_path_str =
"/tmp/tor-rust-directory/hs-dir/hostname".to_string();
Expand Down Expand Up @@ -1951,9 +1945,9 @@ impl Taker {
socks_port,
directory_address,
maker_count,
config.connection_type,
self.config.connection_type,
)?;
let offers = fetch_offer_from_makers(addresses_from_dns, config);
let offers = fetch_offer_from_makers(addresses_from_dns, &self.config);

let new_offers = offers
.into_iter()
Expand Down

0 comments on commit 00388c7

Please sign in to comment.