@@ -14,7 +14,7 @@ use tokio::sync::{
1414 mpsc:: { Receiver , Sender } ,
1515} ;
1616use tokio:: task;
17- use tracing:: { error, info} ;
17+ use tracing:: { debug , error, info} ;
1818
1919pub async fn start_accept_connection (
2020 task_manager : Arc < Mutex < TaskManager > > ,
@@ -33,23 +33,42 @@ pub async fn start_accept_connection(
3333 let _s = tx_mining_notify. subscribe ( ) ;
3434 while let Some ( ( send, recv, addr) ) = downstreams. recv ( ) . await {
3535 info ! ( "Translator opening connection for ip {}" , addr) ;
36-
3736 // The initial difficulty is derived from the formula: difficulty = hash_rate / (shares_per_second * 2^32)
3837 let initial_hash_rate = * crate :: EXPECTED_SV1_HASHPOWER ;
38+ info ! (
39+ "Translator initial hash rate for ip {} is {} H/s" ,
40+ addr, initial_hash_rate
41+ ) ;
3942 let share_per_second = crate :: SHARE_PER_MIN / 60.0 ;
40- let initial_difficulty =
41- dbg ! ( initial_hash_rate / ( share_per_second * 2f32 . powf( 32.0 ) ) ) ;
43+ info ! (
44+ "Translator share per second for ip {} is {} shares/s" ,
45+ addr, share_per_second
46+ ) ;
47+ let initial_difficulty = initial_hash_rate / ( share_per_second * 2f32 . powf ( 32.0 ) ) ;
4248 let initial_difficulty =
4349 crate :: translator:: downstream:: diff_management:: nearest_power_of_10 (
4450 initial_difficulty,
4551 ) ;
46-
52+ info ! (
53+ "Translator initial difficulty for ip {} is {}" ,
54+ addr, initial_difficulty
55+ ) ;
4756 // Formula: expected_hash_rate = (shares_per_second) * initial_difficulty * 2^32, where shares_per_second = SHARE_PER_MIN / 60
4857 let expected_hash_rate =
4958 ( crate :: SHARE_PER_MIN / 60.0 ) * initial_difficulty * 2f32 . powf ( 32.0 ) ;
50- if Bridge :: ready ( & bridge) . await . is_err ( ) {
51- error ! ( "Bridge not ready" ) ;
52- break ;
59+ info ! (
60+ "Translator expected hash rate for ip {} is {} H/s" ,
61+ addr, expected_hash_rate
62+ ) ;
63+
64+ match Bridge :: ready ( & bridge) . await {
65+ Ok ( _) => {
66+ debug ! ( "Bridge is ready, proceeding with connection" ) ;
67+ }
68+ Err ( _) => {
69+ error ! ( "Bridge not ready" ) ;
70+ break ;
71+ }
5372 } ;
5473 let open_sv1_downstream =
5574 match bridge. safe_lock ( |s| s. on_new_sv1_connection ( expected_hash_rate) ) {
0 commit comments