Skip to content

Commit

Permalink
Merge branch 'main' into sim_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkozh authored Mar 5, 2024
2 parents 44bb345 + e2f735b commit b539c7f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/crates/soroban-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ pub struct FullLedgerEntries {

pub struct Client {
base_url: String,
timeout_in_secs: u64,
}

impl Client {
Expand Down Expand Up @@ -580,9 +581,18 @@ impl Client {
tracing::trace!(?uri);
Ok(Self {
base_url: uri.to_string(),
timeout_in_secs: 30,
})
}

/// Create a new client with a timeout in seconds
/// # Errors
pub fn new_with_timeout(base_url: &str, timeout: u64) -> Result<Self, Error> {
let mut client = Self::new(base_url)?;
client.timeout_in_secs = timeout;
Ok(client)
}

///
/// # Errors
fn client(&self) -> Result<HttpClient, Error> {
Expand Down Expand Up @@ -720,7 +730,6 @@ soroban config identity fund {address} --helper-url <url>"#
"SUCCESS" => {
// TODO: the caller should probably be printing this
tracing::trace!("{response:#?}");

return Ok(response);
}
"FAILED" => {
Expand All @@ -737,8 +746,7 @@ soroban config identity fund {address} --helper-url <url>"#
}
};
let duration = start.elapsed();
// TODO: parameterize the timeout instead of using a magic constant
if duration.as_secs() > 10 {
if duration.as_secs() > self.timeout_in_secs {
return Err(Error::TransactionSubmissionTimeout);
}
sleep(Duration::from_secs(1)).await;
Expand Down

0 comments on commit b539c7f

Please sign in to comment.