@@ -175,14 +175,12 @@ pub(crate) struct ConnectionState {
175175
176176pub ( crate ) struct ThreadPool {
177177 pub ( crate ) threads : Mutex < Vec < JoinHandle < ( ) > > > ,
178- pub ( crate ) port : u16 ,
179178}
180179
181180impl ThreadPool {
182- pub ( crate ) fn new ( port : u16 ) -> Self {
181+ pub ( crate ) fn new ( ) -> Self {
183182 Self {
184183 threads : Mutex :: new ( Vec :: new ( ) ) ,
185- port,
186184 }
187185 }
188186
@@ -196,31 +194,22 @@ impl ThreadPool {
196194 . threads
197195 . lock ( )
198196 . map_err ( |_| MakerError :: General ( "Failed to lock threads" ) ) ?;
199-
200197 log:: info!( "Joining {} threads" , threads. len( ) ) ;
201198
202199 let mut joined_count = 0 ;
203200 while let Some ( thread) = threads. pop ( ) {
204- let thread_name = thread. thread ( ) . name ( ) . unwrap ( ) . to_string ( ) ;
205- println ! ( "joining thread: {thread_name}" ) ;
206-
201+ let thread_name = thread. thread ( ) . name ( ) . unwrap_or ( "unknown" ) . to_string ( ) ;
207202 match thread. join ( ) {
208203 Ok ( _) => {
209- log:: info!( "[{}] Thread {} joined" , self . port , thread_name) ;
204+ log:: info!( "Thread {} joined" , thread_name) ;
210205 joined_count += 1 ;
211206 }
212207 Err ( e) => {
213- log:: error!(
214- "[{}] Error {:?} while joining thread {}" ,
215- self . port,
216- e,
217- thread_name
218- ) ;
208+ log:: error!( "Error {:?} while joining thread {}" , e, thread_name) ;
219209 }
220210 }
221211 }
222-
223- log:: info!( "Successfully joined {joined_count} threads" , ) ;
212+ log:: info!( "Successfully joined {joined_count} threads" ) ;
224213 Ok ( ( ) )
225214 }
226215}
@@ -324,8 +313,6 @@ impl Maker {
324313 log:: info!( "Sync at:----Maker init----" ) ;
325314 wallet. sync_and_save ( ) ?;
326315
327- let network_port = config. network_port ;
328-
329316 Ok ( Self {
330317 behavior,
331318 config,
@@ -335,7 +322,7 @@ impl Maker {
335322 highest_fidelity_proof : RwLock :: new ( None ) ,
336323 is_setup_complete : AtomicBool :: new ( false ) ,
337324 data_dir,
338- thread_pool : Arc :: new ( ThreadPool :: new ( network_port ) ) ,
325+ thread_pool : Arc :: new ( ThreadPool :: new ( ) ) ,
339326 watch_service,
340327 } )
341328 }
@@ -619,18 +606,14 @@ pub(crate) fn check_for_broadcasted_contracts(maker: Arc<Maker>) -> Result<(), M
619606 if transaction_broadcasted {
620607 // Something is broadcasted. Report, Recover and Abort.
621608 log:: warn!(
622- "[{}] Contract txs broadcasted!! txid: {} Recovering from ongoing swaps." ,
623- maker. config. network_port,
609+ "Contract txs broadcasted!! txid: {} Recovering from ongoing swaps." ,
624610 txid
625611 ) ;
626612 failed_swap_ip. push ( ip. clone ( ) ) ;
627613
628614 // Spawn a separate thread to wait for contract maturity and broadcasting timelocked/hashlocked.
629615 let maker_clone = maker. clone ( ) ;
630- log:: info!(
631- "[{}] Spawning recovery thread after seeing contracts in mempool" ,
632- maker. config. network_port
633- ) ;
616+ log:: info!( "Spawning recovery thread after seeing contracts in mempool" , ) ;
634617
635618 let incomings = connection_state. incoming_swapcoins . clone ( ) ;
636619 let outgoings = connection_state. outgoing_swapcoins . clone ( ) ;
@@ -705,17 +688,13 @@ pub(crate) fn check_for_idle_states(maker: Arc<Maker>) -> Result<(), MakerError>
705688
706689 if no_response_since > IDLE_CONNECTION_TIMEOUT {
707690 log:: error!(
708- "[{}] Potential Dropped Connection from taker. No response since : {} secs. Recovering from swap" ,
709- maker. config. network_port,
691+ "Potential Dropped Connection from taker. No response since : {} secs. Recovering from swap" ,
710692 no_response_since. as_secs( )
711693 ) ;
712694 bad_ip. push ( ip. clone ( ) ) ;
713695 // Spawn a separate thread to wait for contract maturity and broadcasting timelocked,hashlocked
714696 let maker_clone = maker. clone ( ) ;
715- log:: info!(
716- "[{}] Spawning recovery thread after Taker dropped" ,
717- maker. config. network_port
718- ) ;
697+ log:: info!( "Spawning recovery thread after Taker dropped" , ) ;
719698
720699 let incomings = state. incoming_swapcoins . clone ( ) ;
721700 let outgoings = state. outgoing_swapcoins . clone ( ) ;
@@ -766,8 +745,7 @@ pub(crate) fn recover_from_swap(
766745 let timelock_expiry = start_height. saturating_add ( timelock) ;
767746
768747 log:: info!(
769- "[{}] recover_from_swap started | height={} timelock_expiry={}" ,
770- maker. config. network_port,
748+ "recover_from_swap started | height={} timelock_expiry={}" ,
771749 start_height,
772750 timelock_expiry
773751 ) ;
@@ -782,8 +760,7 @@ pub(crate) fn recover_from_swap(
782760
783761 if current_height >= timelock_expiry {
784762 log:: info!(
785- "[{}] timelock expired at {} (expiry={}), using timelock path" ,
786- maker. config. network_port,
763+ "timelock expired at {} (expiry={}), using timelock path" ,
787764 current_height,
788765 timelock_expiry
789766 ) ;
@@ -802,8 +779,7 @@ pub(crate) fn recover_from_swap(
802779
803780 if all_preimages_known {
804781 log:: info!(
805- "[{}] all preimages known at height {}, using hashlock path" ,
806- maker. config. network_port,
782+ "all preimages known at height {}, using hashlock path" ,
807783 current_height
808784 ) ;
809785 return recover_via_hashlock ( maker, incoming_swapcoins) ;
@@ -830,8 +806,7 @@ fn recover_via_hashlock(
830806 . write ( ) ?
831807 . spend_from_hashlock_contract ( & infos, & maker. watch_service ) ?;
832808 log:: info!(
833- "[{}] Maker hashlock recovery: {}/{} txs broadcasted" ,
834- maker. config. network_port,
809+ "Maker hashlock recovery: {}/{} txs broadcasted" ,
835810 broadcasted. len( ) ,
836811 incoming. len( )
837812 ) ;
@@ -885,8 +860,7 @@ fn recover_via_timelock(
885860 . write ( ) ?
886861 . spend_from_timelock_contract ( & infos, & maker. watch_service ) ?;
887862 log:: info!(
888- "[{}] Maker timelock recovery: {}/{} txs broadcasted" ,
889- maker. config. network_port,
863+ "Maker timelock recovery: {}/{} txs broadcasted" ,
890864 broadcasted. len( ) ,
891865 outgoing. len( )
892866 ) ;
@@ -943,11 +917,7 @@ fn check_for_watch_response(
943917 }
944918
945919 for transaction in responses {
946- log:: info!(
947- "[{}] Received WatchResponse with mempool txs: {:?}" ,
948- maker. config. network_port,
949- transaction
950- ) ;
920+ log:: info!( "Received WatchResponse with mempool txs: {:?}" , transaction) ;
951921
952922 for input in & transaction. input {
953923 let outpoint = ( input. previous_output . txid , input. previous_output . vout ) ;
@@ -1001,8 +971,7 @@ fn update_swapcoins_with_preimages<T: SwapCoin>(
1001971 let redeemscript = coin. get_multisig_redeemscript ( ) ;
1002972 if apply_preimage ( & redeemscript, * preimage) {
1003973 log:: info!(
1004- "[{}] Applied preimage for {} swapcoin {:?}" ,
1005- maker. config. network_port,
974+ "Applied preimage for {} swapcoin {:?}" ,
1006975 if is_incoming { "incoming" } else { "outgoing" } ,
1007976 redeemscript
1008977 ) ;
0 commit comments