Skip to content

Commit

Permalink
Changed block subscription from finalized to best (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed authored Jun 23, 2023
1 parent 95ef96f commit 451f027
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ pub async fn subscribe_stats(
url: &str,
) -> Result<impl TryStream<Ok = BlockStats, Error = Error> + Unpin, Error> {
let client = OnlineClient::<DefaultConfig>::from_url(url).await?;
subscribe_stats_with_client(client).await
}

/// Connect to the specified node and listen for new blocks using OnlineClient.
pub async fn subscribe_stats_with_client(
client: OnlineClient<DefaultConfig>,
) -> Result<impl TryStream<Ok = BlockStats, Error = Error> + Unpin, Error> {
let client = Arc::new(client);

let blocks = client.blocks().subscribe_finalized().await?;
let blocks = client.blocks().subscribe_best().await?;

let max_block_weights: BlockWeights = {
let metadata = client.metadata();
Expand Down

0 comments on commit 451f027

Please sign in to comment.