Skip to content

Commit

Permalink
Remove the duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Mar 27, 2024
1 parent 3b2d7d8 commit a60ab41
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sdk/src/wallet/operations/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ where
.await;

log::debug!("submitting block {}", block.id(&protocol_parameters));
for attempt in 1..MAX_POST_BLOCK_ATTEMPTS {
if let Ok(block_id) = self.client().post_block(&block).await {
log::debug!("submitted block {}", block_id);
return Ok(block_id);
log::debug!("submitting block {block:?}");

let mut attempt = 1;
loop {
match self.client().post_block(&block).await {
Ok(block_id) => break Ok(block_id),
Err(err) => {
if attempt >= MAX_POST_BLOCK_ATTEMPTS {
return Err(err.into());
}
}
}
tokio::time::sleep(std::time::Duration::from_secs(attempt)).await;
attempt += 1;
}

log::debug!("submitting block {block:?}");

let block_id = self.client().post_block(&block).await?;

log::debug!("submitted block {block_id}");

Ok(block_id)
}
}

0 comments on commit a60ab41

Please sign in to comment.