Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed jitter from interact transaction fetch #1632

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion framework/snippets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ base64 = "0.22"
log = "0.4.17"
env_logger = "0.11"
futures = "0.3"
rand = "0.8.5"

[dependencies.multiversx-sc-scenario]
version = "=0.50.1"
Expand Down
6 changes: 1 addition & 5 deletions framework/snippets/src/interactor_retrieve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::Interactor;
use log::info;
use multiversx_sdk::data::transaction::TransactionOnNetwork;
use rand::Rng;
use std::time::{Duration, Instant};

const INITIAL_BACKOFF_DELAY: f32 = 1.4;
Expand All @@ -11,7 +10,6 @@ const MAX_BACKOFF_DELAY: Duration = Duration::from_secs(6);
impl Interactor {
/// Retrieves a transaction from the network.
pub(crate) async fn retrieve_tx_on_network(&self, tx_hash: String) -> TransactionOnNetwork {
let mut rng = rand::thread_rng();
let mut retries = 0;
let mut backoff_delay = Duration::from_secs_f32(INITIAL_BACKOFF_DELAY);
let start_time = Instant::now();
Expand Down Expand Up @@ -47,9 +45,7 @@ impl Interactor {
break;
}

let backoff_time = backoff_delay
.mul_f32(rng.gen_range(0.8..1.2))
.min(MAX_BACKOFF_DELAY);
let backoff_time = backoff_delay.min(MAX_BACKOFF_DELAY);
tokio::time::sleep(backoff_time).await;
backoff_delay *= 2; // exponential backoff
},
Expand Down
Loading