mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-18 05:59:33 +00:00
Merge pull request #370 from logos-blockchain/Pravdyvy/matched-retry-on-inscription
Branched retry on inscriptions
This commit is contained in:
commit
b94b58ceb1
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -5531,7 +5531,6 @@ dependencies = [
|
|||||||
name = "nssa"
|
name = "nssa"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amm_core",
|
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"borsh",
|
"borsh",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
|||||||
@ -31,9 +31,9 @@ impl Default for BackoffConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple wrapper
|
/// Simple wrapper
|
||||||
// maybe extend in the future for our purposes
|
/// maybe extend in the future for our purposes
|
||||||
// `Clone` is cheap because `CommonHttpClient` is internally reference counted (`Arc`).
|
/// `Clone` is cheap because `CommonHttpClient` is internally reference counted (`Arc`).
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct BedrockClient {
|
pub struct BedrockClient {
|
||||||
http_client: CommonHttpClient,
|
http_client: CommonHttpClient,
|
||||||
@ -62,10 +62,22 @@ impl BedrockClient {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn post_transaction(&self, tx: SignedMantleTx) -> Result<(), Error> {
|
pub async fn post_transaction(&self, tx: SignedMantleTx) -> Result<Result<(), Error>, Error> {
|
||||||
Retry::spawn(self.backoff_strategy(), || {
|
Retry::spawn(self.backoff_strategy(), || async {
|
||||||
self.http_client
|
match self
|
||||||
|
.http_client
|
||||||
.post_transaction(self.node_url.clone(), tx.clone())
|
.post_transaction(self.node_url.clone(), tx.clone())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(()) => Ok(Ok(())),
|
||||||
|
Err(err) => match err {
|
||||||
|
// Retry arm.
|
||||||
|
// Retrying only reqwest errors: mainly connected to http.
|
||||||
|
Error::Request(_) => Err(err),
|
||||||
|
// Returning non-retryable error
|
||||||
|
Error::Server(_) | Error::Client(_) | Error::Url(_) => Ok(Err(err)),
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,8 @@ impl BlockSettlementClientTrait for BlockSettlementClient {
|
|||||||
self.client
|
self.client
|
||||||
.post_transaction(tx)
|
.post_transaction(tx)
|
||||||
.await
|
.await
|
||||||
.context("Failed to post transaction to Bedrock")?;
|
.context("Failed to post transaction to Bedrock after retries")?
|
||||||
|
.context("Failed to post transaction to Bedrock with non-retryable error")?;
|
||||||
|
|
||||||
log::debug!("Posted block to Bedrock with parent id {parent_id:?} and msg id: {msg_id:?}");
|
log::debug!("Posted block to Bedrock with parent id {parent_id:?} and msg id: {msg_id:?}");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user