11use crate :: tree:: metrics:: BlockBufferMetrics ;
22use alloy_consensus:: BlockHeader ;
33use alloy_primitives:: { BlockHash , BlockNumber } ;
4- use reth_primitives_traits:: { Block , RecoveredBlock } ;
4+ use reth_primitives_traits:: { Block , SealedBlock } ;
55use std:: collections:: { BTreeMap , HashMap , HashSet , VecDeque } ;
66
77/// Contains the tree of pending blocks that cannot be executed due to missing parent.
@@ -18,7 +18,7 @@ use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
1818#[ derive( Debug ) ]
1919pub struct BlockBuffer < B : Block > {
2020 /// All blocks in the buffer stored by their block hash.
21- pub ( crate ) blocks : HashMap < BlockHash , RecoveredBlock < B > > ,
21+ pub ( crate ) blocks : HashMap < BlockHash , SealedBlock < B > > ,
2222 /// Map of any parent block hash (even the ones not currently in the buffer)
2323 /// to the buffered children.
2424 /// Allows connecting buffered blocks by parent.
@@ -49,12 +49,12 @@ impl<B: Block> BlockBuffer<B> {
4949 }
5050
5151 /// Return reference to the requested block.
52- pub fn block ( & self , hash : & BlockHash ) -> Option < & RecoveredBlock < B > > {
52+ pub fn block ( & self , hash : & BlockHash ) -> Option < & SealedBlock < B > > {
5353 self . blocks . get ( hash)
5454 }
5555
5656 /// Return a reference to the lowest ancestor of the given block in the buffer.
57- pub fn lowest_ancestor ( & self , hash : & BlockHash ) -> Option < & RecoveredBlock < B > > {
57+ pub fn lowest_ancestor ( & self , hash : & BlockHash ) -> Option < & SealedBlock < B > > {
5858 let mut current_block = self . blocks . get ( hash) ?;
5959 while let Some ( parent) = self . blocks . get ( & current_block. parent_hash ( ) ) {
6060 current_block = parent;
@@ -63,7 +63,7 @@ impl<B: Block> BlockBuffer<B> {
6363 }
6464
6565 /// Insert a correct block inside the buffer.
66- pub fn insert_block ( & mut self , block : RecoveredBlock < B > ) {
66+ pub fn insert_block ( & mut self , block : SealedBlock < B > ) {
6767 let hash = block. hash ( ) ;
6868
6969 self . parent_to_child . entry ( block. parent_hash ( ) ) . or_default ( ) . insert ( hash) ;
@@ -87,10 +87,7 @@ impl<B: Block> BlockBuffer<B> {
8787 ///
8888 /// Note: that order of returned blocks is important and the blocks with lower block number
8989 /// in the chain will come first so that they can be executed in the correct order.
90- pub fn remove_block_with_children (
91- & mut self ,
92- parent_hash : & BlockHash ,
93- ) -> Vec < RecoveredBlock < B > > {
90+ pub fn remove_block_with_children ( & mut self , parent_hash : & BlockHash ) -> Vec < SealedBlock < B > > {
9491 let removed = self
9592 . remove_block ( parent_hash)
9693 . into_iter ( )
@@ -149,7 +146,7 @@ impl<B: Block> BlockBuffer<B> {
149146 /// This method will only remove the block if it's present inside `self.blocks`.
150147 /// The block might be missing from other collections, the method will only ensure that it has
151148 /// been removed.
152- fn remove_block ( & mut self , hash : & BlockHash ) -> Option < RecoveredBlock < B > > {
149+ fn remove_block ( & mut self , hash : & BlockHash ) -> Option < SealedBlock < B > > {
153150 let block = self . blocks . remove ( hash) ?;
154151 self . remove_from_earliest_blocks ( block. number ( ) , hash) ;
155152 self . remove_from_parent ( block. parent_hash ( ) , hash) ;
@@ -158,7 +155,7 @@ impl<B: Block> BlockBuffer<B> {
158155 }
159156
160157 /// Remove all children and their descendants for the given blocks and return them.
161- fn remove_children ( & mut self , parent_hashes : Vec < BlockHash > ) -> Vec < RecoveredBlock < B > > {
158+ fn remove_children ( & mut self , parent_hashes : Vec < BlockHash > ) -> Vec < SealedBlock < B > > {
162159 // remove all parent child connection and all the child children blocks that are connected
163160 // to the discarded parent blocks.
164161 let mut remove_parent_children = parent_hashes;
@@ -184,7 +181,6 @@ mod tests {
184181 use super :: * ;
185182 use alloy_eips:: BlockNumHash ;
186183 use alloy_primitives:: BlockHash ;
187- use reth_primitives_traits:: RecoveredBlock ;
188184 use reth_testing_utils:: generators:: { self , random_block, BlockParams , Rng } ;
189185 use std:: collections:: HashMap ;
190186
@@ -193,10 +189,8 @@ mod tests {
193189 rng : & mut R ,
194190 number : u64 ,
195191 parent : BlockHash ,
196- ) -> RecoveredBlock < reth_ethereum_primitives:: Block > {
197- let block =
198- random_block ( rng, number, BlockParams { parent : Some ( parent) , ..Default :: default ( ) } ) ;
199- block. try_recover ( ) . unwrap ( )
192+ ) -> SealedBlock < reth_ethereum_primitives:: Block > {
193+ random_block ( rng, number, BlockParams { parent : Some ( parent) , ..Default :: default ( ) } )
200194 }
201195
202196 /// Assert that all buffer collections have the same data length.
@@ -216,7 +210,7 @@ mod tests {
216210 /// Assert that the block was removed from all buffer collections.
217211 fn assert_block_removal < B : Block > (
218212 buffer : & BlockBuffer < B > ,
219- block : & RecoveredBlock < reth_ethereum_primitives:: Block > ,
213+ block : & SealedBlock < reth_ethereum_primitives:: Block > ,
220214 ) {
221215 assert ! ( !buffer. blocks. contains_key( & block. hash( ) ) ) ;
222216 assert ! ( buffer
0 commit comments