mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
chore: add size field in the new_header_stream method (#17008)
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user