pub struct Cursor {
pub block_number: u64,
pub block_hash: String,
pub confirmation_depth: u64,
}Expand description
The indexer’s current position in the chain.
The cursor knows:
- Which block was last successfully processed
- The confirmation depth (how many blocks behind head we consider “confirmed”)
Fields§
§block_number: u64Last confirmed block number that was processed.
block_hash: StringLast confirmed block hash.
confirmation_depth: u64Minimum number of confirmations before processing a block.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn new(
block_number: u64,
block_hash: impl Into<String>,
confirmation_depth: u64,
) -> Self
pub fn new( block_number: u64, block_hash: impl Into<String>, confirmation_depth: u64, ) -> Self
Create a new cursor at the given starting position.
Sourcepub fn advance(&mut self, block_number: u64, block_hash: impl Into<String>)
pub fn advance(&mut self, block_number: u64, block_hash: impl Into<String>)
Advance the cursor to a new confirmed block.
Sourcepub fn is_confirmed(&self, target: u64, head_number: u64) -> bool
pub fn is_confirmed(&self, target: u64, head_number: u64) -> bool
Returns true if head_number is far enough ahead for target to be confirmed.
Sourcepub fn next_block(&self) -> u64
pub fn next_block(&self) -> u64
Returns the next block to process (cursor + 1).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cursor
impl<'de> Deserialize<'de> for Cursor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnsafeUnpin for Cursor
impl UnwindSafe for Cursor
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