Skip to content

Commit

Permalink
Fix documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Nov 6, 2023
1 parent 2476600 commit bbc38db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 11 additions & 8 deletions examples/list-all-transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ async fn main() -> anyhow::Result<()> {
};
// Query blocks by increasing height.
let mut block_stream = client.get_finalized_blocks_from(h).await?;
while let Ok((timeout, chunk)) = block_stream
.next_chunk_timeout(app.num as usize, std::time::Duration::from_millis(500))
.await
{
loop {
let Ok((error, chunk)) = block_stream
.next_chunk_timeout(app.num as usize, std::time::Duration::from_millis(500))
.await
else {
// if we failed and end time is not yet here, then wait a bit
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
continue;
};
let mut handles = Vec::with_capacity(app.num as usize);
for block in chunk {
let mut cc = client.clone();
Expand Down Expand Up @@ -133,10 +138,8 @@ async fn main() -> anyhow::Result<()> {
}
}
}
if timeout {
// if we failed and end time is not yet here, then wait a bit
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
if error {
anyhow::bail!("Finalized blocks vanished.")
}
}
Ok(())
}
7 changes: 3 additions & 4 deletions src/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2774,10 +2774,9 @@ impl FinalizedBlocksStream {
/// occurred (it is `true` if an error occurred) while getting blocks.
/// If that is the case further calls will always yield an error.
///
/// The first field of the response indicates if an error occurred, either
/// due to a timeout or the receiver channel was disconnected.
/// Concretely, if no blocks are available in time then `Ok((true,
/// Vec::new()))` is returned.
/// The first field of the response indicates if an error occurred. This
/// will only happen if the stream of finalized blocks has unexpectedly
/// dropped.
pub async fn next_chunk_timeout(
&mut self,
n: usize,
Expand Down

0 comments on commit bbc38db

Please sign in to comment.