Skip to content

Commit

Permalink
fix: fixed make-it-rain delay (#6165)
Browse files Browse the repository at this point in the history
Description
---
Fixed make-it-rain delay

Motivation and Context
---
The delay did not work properly

How Has This Been Tested?
---
System-level testing (`make-it-rain --stealth --duration 7200
--transactions-per-second 1 --start-amount 0.039000T --increase-amount
0T --start-time now --message Brian_01_(stealth)
d035876f990517ff2629d7acbba9c86a760412f12c029119e545ec2f1bda1f1ec1`)

What process can a PR reviewer use to test or verify this change?
---
Code walk-through
System-level testing 

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal authored Feb 26, 2024
1 parent f5860a8 commit 5c5da46
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,19 @@ pub async fn make_it_rain(

// Manage transaction submission rate
let actual_ms = (Utc::now() - started_at).num_milliseconds();
let target_ms = (i as f64 / f64::from(transactions_per_second) / 1000.0) as i64;
let target_ms = (i as f64 * (1000.0 / f64::from(transactions_per_second))) as i64;
trace!(
target: LOG_TARGET,
"make-it-rain {}: target {:?} ms vs. actual {:?} ms", i, target_ms, actual_ms
);
if target_ms - actual_ms > 0 {
// Maximum delay between Txs set to 120 s
sleep(Duration::from_millis((target_ms - actual_ms).min(120_000i64) as u64)).await;
let delay_ms = Duration::from_millis((target_ms - actual_ms).min(120_000i64) as u64);
trace!(
target: LOG_TARGET,
"make-it-rain {}: delaying for {:?} ms", i, delay_ms
);
sleep(delay_ms).await;
}
let delayed_for = Instant::now();
let sender_clone = sender.clone();
Expand Down

0 comments on commit 5c5da46

Please sign in to comment.