Skip to content

Commit

Permalink
fix(client): wait a short while before startup quoting/upload tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and jacderida committed Dec 16, 2024
1 parent 2e1d830 commit 491b24e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ jobs:
if: matrix.os != 'windows-latest'
run: |
set -e
for i in {1..100}; do
for i in {1..50}; do
dd if=/dev/urandom of=random_file_$i.bin bs=1M count=1 status=none
./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin --public
./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin
Expand All @@ -423,7 +423,7 @@ jobs:
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
for ($i = 1; $i -le 100; $i++) {
for ($i = 1; $i -le 50; $i++) {
$fileName = "random_file_$i.bin"
$byteArray = [byte[]]@(0xFF) * (1MB) # Create a 1 MB array filled with 0xFF
[System.IO.File]::WriteAllBytes($fileName, $byteArray)
Expand Down
6 changes: 4 additions & 2 deletions ant-node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use ant_bootstrap::BootstrapCacheStore;
use ant_evm::RewardsAddress;
#[cfg(feature = "open-metrics")]
use ant_networking::MetricsRegistries;
use ant_networking::{Instant, Network, NetworkBuilder, NetworkEvent, NodeIssue, SwarmDriver};
use ant_networking::{
target_arch::sleep, Instant, Network, NetworkBuilder, NetworkEvent, NodeIssue, SwarmDriver,
};
use ant_protocol::{
convert_distance_to_u256,
error::Error as ProtocolError,
Expand Down Expand Up @@ -969,7 +971,7 @@ impl Node {
}
}
// Sleep a short while to avoid causing a spike on resource usage.
std::thread::sleep(std::time::Duration::from_secs(10));
sleep(std::time::Duration::from_secs(10)).await;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions autonomi/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ impl Client {
receiver.await.expect("sender should not close")?;
debug!("Client is connected to the network");

// With the switch to the new bootstrap cache scheme,
// Seems the too many `initial dial`s could result in failure,
// when startup quoting/upload tasks got started up immediatly.
// Hence, put in a forced wait to allow `initial network discovery` to be completed.
ant_networking::target_arch::sleep(Duration::from_secs(5)).await;

Ok(Self {
network,
client_event_sender: Arc::new(None),
Expand Down

0 comments on commit 491b24e

Please sign in to comment.