pub struct ReorgWindow { /* private fields */ }Expand description
Sliding window of block hashes used during reorg detection.
Implementations§
Source§impl ReorgWindow
impl ReorgWindow
Sourcepub fn new(limit: usize) -> Self
pub fn new(limit: usize) -> Self
Creates a new reorg window with the specified size limit.
The limit is clamped to a minimum of 1.
Sourcepub fn push(&mut self, height: u64, hash: BlockHash)
pub fn push(&mut self, height: u64, hash: BlockHash)
Adds a block to the window, evicting the oldest entry if the limit is reached.
Sourcepub fn find_hash(&self, hash: &BlockHash) -> Option<u64>
pub fn find_hash(&self, hash: &BlockHash) -> Option<u64>
Searches for a block hash in the window and returns its height if found.
The search starts from the most recent block.
Sourcepub fn truncate_after(&mut self, height: u64)
pub fn truncate_after(&mut self, height: u64)
Removes entries whose height is greater than the provided value while keeping the older portion of the window intact.
Trait Implementations§
Source§impl Clone for ReorgWindow
impl Clone for ReorgWindow
Source§fn clone(&self) -> ReorgWindow
fn clone(&self) -> ReorgWindow
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ReorgWindow
impl RefUnwindSafe for ReorgWindow
impl Send for ReorgWindow
impl Sync for ReorgWindow
impl Unpin for ReorgWindow
impl UnwindSafe for ReorgWindow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more