Skip to content

Commit 8281514

Browse files
committed
proxy execute w tba wip
1 parent 98a012d commit 8281514

File tree

3 files changed

+402
-24
lines changed

3 files changed

+402
-24
lines changed

src/eth.rs

+39-14
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ use std::collections::{HashMap, HashSet};
1414
use std::error::Error;
1515
use std::fmt;
1616

17-
// TODO: remove this
18-
use crate::kiprintln;
19-
2017
/// Subscription kind. Pulled directly from alloy (https://github.com/alloy-rs/alloy).
2118
/// Why? Because alloy is not yet 1.0 and the types in this interface must be stable.
2219
/// If alloy SubscriptionKind changes, we can implement a transition function in runtime
@@ -338,9 +335,6 @@ impl Provider {
338335
.unwrap()
339336
.map_err(|_| EthError::RpcTimeout)?;
340337

341-
//TODO: remove
342-
//kiprintln!("PROCESS_LIB::send_request_and_parse_response resp: {:#?}", resp);
343-
344338
match resp {
345339
Message::Response { body, .. } => match serde_json::from_slice::<EthResponse>(&body) {
346340
Ok(EthResponse::Response(value)) => {
@@ -705,8 +699,6 @@ impl Provider {
705699
// NOTE: tx must be encased by a tuple to be serialized correctly
706700
params: serde_json::to_value((tx,)).unwrap(),
707701
};
708-
//TODO: remove
709-
kiprintln!("PROCESS_LIB::send_raw_transaction action: {:#?}", action);
710702

711703
self.send_request_and_parse_response::<TxHash>(action)
712704
}
@@ -764,21 +756,54 @@ impl Provider {
764756
print_verbosity_success: u8,
765757
print_verbosity_error: u8,
766758
) {
759+
let mut delay_secs = 5; // Initial delay
760+
const MAX_DELAY_SECS: u64 = 60; // Maximum delay
761+
767762
loop {
768763
match self.subscribe(sub_id, filter.clone()) {
769-
Ok(()) => break,
770-
Err(_) => {
764+
Ok(()) => break, // Success, exit loop
765+
Err(e) => { // Log the actual error
771766
crate::print_to_terminal(
772767
print_verbosity_error,
773-
"failed to subscribe to chain! trying again in 5s...",
768+
&format!(
769+
"Failed to subscribe to chain (sub_id {}): {:?}. Retrying in {}s...",
770+
sub_id, e, delay_secs
771+
),
774772
);
775-
std::thread::sleep(std::time::Duration::from_secs(5));
776-
continue;
773+
std::thread::sleep(std::time::Duration::from_secs(delay_secs));
774+
// Increase delay for next attempt, capped at maximum
775+
delay_secs = (delay_secs * 2).min(MAX_DELAY_SECS);
776+
continue; // Retry
777777
}
778778
}
779779
}
780-
crate::print_to_terminal(print_verbosity_success, "subscribed to logs successfully");
780+
crate::print_to_terminal(
781+
print_verbosity_success,
782+
&format!("Subscribed successfully (sub_id {})", sub_id),
783+
);
781784
}
785+
//pub fn subscribe_loop(
786+
// &self,
787+
// sub_id: u64,
788+
// filter: Filter,
789+
// print_verbosity_success: u8,
790+
// print_verbosity_error: u8,
791+
//) {
792+
// loop {
793+
// match self.subscribe(sub_id, filter.clone()) {
794+
// Ok(()) => break,
795+
// Err(_) => {
796+
// crate::print_to_terminal(
797+
// print_verbosity_error,
798+
// "failed to subscribe to chain! trying again in 5s...",
799+
// );
800+
// std::thread::sleep(std::time::Duration::from_secs(5));
801+
// continue;
802+
// }
803+
// }
804+
// }
805+
// crate::print_to_terminal(print_verbosity_success, "subscribed to logs successfully");
806+
//}
782807

783808
/// Unsubscribes from a previously created subscription.
784809
///

src/signer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'de> Deserialize<'de> for LocalSigner {
140140
{
141141
#[derive(Deserialize)]
142142
struct LocalSignerData {
143-
address: EthAddress,
143+
_address: EthAddress,
144144
chain_id: u64,
145145
private_key_hex: String,
146146
}

0 commit comments

Comments
 (0)