@@ -8,7 +8,7 @@ use builder::config::HostProvider;
8
8
use init4_bin_base:: {
9
9
deps:: {
10
10
metrics:: { counter, histogram} ,
11
- tracing,
11
+ tracing:: { debug , error } ,
12
12
} ,
13
13
init4,
14
14
utils:: { from_env:: FromEnv , signer:: LocalOrAwsConfig } ,
@@ -44,16 +44,17 @@ async fn main() {
44
44
let _guard = init4 ( ) ;
45
45
46
46
let config = Config :: from_env ( ) . unwrap ( ) ;
47
- tracing:: trace!( "connecting to provider" ) ;
47
+ debug ! ( ?config. recipient_address, "connecting to provider" ) ;
48
+
48
49
let provider = config. provider ( ) . await ;
49
50
let recipient_address = config. recipient_address ;
50
51
let sleep_time = config. sleep_time ;
51
52
52
53
loop {
53
- tracing :: debug!( "attempting transaction" ) ;
54
+ debug ! ( ?recipient_address , "attempting transaction" ) ;
54
55
send_transaction ( & provider, recipient_address) . await ;
55
56
56
- tracing :: debug!( sleep_time, "sleeping" ) ;
57
+ debug ! ( sleep_time, "sleeping" ) ;
57
58
tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( sleep_time) ) . await ;
58
59
}
59
60
}
@@ -70,18 +71,17 @@ async fn send_transaction(provider: &HostProvider, recipient_address: Address) {
70
71
let dispatch_start_time: Instant = Instant :: now ( ) ;
71
72
72
73
// dispatch the transaction
73
- tracing:: debug!( "dispatching transaction" ) ;
74
74
let result = provider. send_transaction ( tx) . await . unwrap ( ) ;
75
75
76
76
// wait for the transaction to mine
77
77
let receipt = match timeout ( Duration :: from_secs ( 240 ) , result. get_receipt ( ) ) . await {
78
78
Ok ( Ok ( receipt) ) => receipt,
79
79
Ok ( Err ( e) ) => {
80
- tracing :: error!( error = ?e, "failed to get transaction receipt" ) ;
80
+ error ! ( error = ?e, "failed to get transaction receipt" ) ;
81
81
return ;
82
82
}
83
83
Err ( _) => {
84
- tracing :: error!( "timeout waiting for transaction receipt" ) ;
84
+ error ! ( "timeout waiting for transaction receipt" ) ;
85
85
counter ! ( "txn_submitter.tx_timeout" ) . increment ( 1 ) ;
86
86
return ;
87
87
}
@@ -91,6 +91,6 @@ async fn send_transaction(provider: &HostProvider, recipient_address: Address) {
91
91
92
92
// record metrics for how long it took to mine the transaction
93
93
let mine_time = dispatch_start_time. elapsed ( ) . as_secs ( ) ;
94
- tracing :: debug!( success = receipt. status( ) , mine_time, hash, "transaction mined" ) ;
94
+ debug ! ( success = receipt. status( ) , mine_time, hash, "transaction mined" ) ;
95
95
histogram ! ( "txn_submitter.tx_mine_time" ) . record ( mine_time as f64 ) ;
96
96
}
0 commit comments