Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take TakerConfig from struct instead of having parameter for it. #259

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading