chore: add size field in the new_header_stream method (#17008)

This commit is contained in:
Krishang Shah
2025-06-23 19:03:48 +05:30
committed by GitHub
parent 93a407b560
commit 0d5edc240b

View File

@@ -2,7 +2,7 @@
use std::sync::Arc;
use alloy_primitives::TxHash;
use alloy_primitives::{TxHash, U256};
use alloy_rpc_types_eth::{
pubsub::{Params, PubSubSyncStatus, SubscriptionKind, SyncStatusMetadata},
Filter, Header, Log,
@@ -353,10 +353,18 @@ where
/// Returns a stream that yields all new RPC blocks.
fn new_headers_stream(&self) -> impl Stream<Item = Header<N::BlockHeader>> {
self.eth_api.provider().canonical_state_stream().flat_map(|new_chain| {
let headers = new_chain.committed().headers().collect::<Vec<_>>();
futures::stream::iter(
headers.into_iter().map(|h| Header::from_consensus(h.into(), None, None)),
)
let headers = new_chain
.committed()
.blocks_iter()
.map(|block| {
Header::from_consensus(
block.clone_sealed_header().into(),
None,
Some(U256::from(block.rlp_length())),
)
})
.collect::<Vec<_>>();
futures::stream::iter(headers)
})
}