pub struct VsdbBlockStore { /* private fields */ }Expand description
Persistent block store backed by vsdb
Implementations§
Source§impl VsdbBlockStore
impl VsdbBlockStore
Sourcepub fn open(data_dir: &Path) -> Result<Self>
pub fn open(data_dir: &Path) -> Result<Self>
Opens an existing block store or creates a fresh one.
Must be called after vsdb::vsdb_set_base_dir.
The instance IDs of the internal collections are stored in
data_dir/block_store.meta. On first run the file is created;
on subsequent runs the collections are recovered from saved IDs.
Backward-compatible: 24-byte meta (v1, 3 collections) is auto-migrated to 40 bytes (v2, 5 collections) on first open.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new in-memory block store without any persistent meta file.
Intended for unit tests only; use Self::open in production.
pub fn contains(&self, hash: &BlockHash) -> bool
pub fn flush(&self)
Trait Implementations§
Source§impl BlockStore for VsdbBlockStore
impl BlockStore for VsdbBlockStore
fn put_block(&mut self, block: Block)
fn get_block(&self, hash: &BlockHash) -> Option<Block>
fn get_block_by_height(&self, h: Height) -> Option<Block>
Source§fn get_blocks_in_range(&self, from: Height, to: Height) -> Vec<Block>
fn get_blocks_in_range(&self, from: Height, to: Height) -> Vec<Block>
Get blocks in [from, to] inclusive. Default iterates one-by-one.
Source§fn tip_height(&self) -> Height
fn tip_height(&self) -> Height
Return the highest stored block height.
Source§fn put_commit_qc(&mut self, height: Height, qc: QuorumCertificate)
fn put_commit_qc(&mut self, height: Height, qc: QuorumCertificate)
Store the QC that committed a block at the given height.
Source§fn get_commit_qc(&self, height: Height) -> Option<QuorumCertificate>
fn get_commit_qc(&self, height: Height) -> Option<QuorumCertificate>
Retrieve the commit QC for a block at the given height.
Source§fn put_tx_index(&mut self, tx_hash: [u8; 32], height: Height, index: u32)
fn put_tx_index(&mut self, tx_hash: [u8; 32], height: Height, index: u32)
Store a tx hash → (height, index) mapping.
Source§fn get_tx_location(&self, tx_hash: &[u8; 32]) -> Option<(Height, u32)>
fn get_tx_location(&self, tx_hash: &[u8; 32]) -> Option<(Height, u32)>
Look up a tx hash → (height, index_in_block).
Source§fn put_block_results(&mut self, height: Height, results: EndBlockResponse)
fn put_block_results(&mut self, height: Height, results: EndBlockResponse)
Store the EndBlockResponse for a given height.
Source§fn get_block_results(&self, height: Height) -> Option<EndBlockResponse>
fn get_block_results(&self, height: Height) -> Option<EndBlockResponse>
Retrieve the EndBlockResponse for a given height.
Auto Trait Implementations§
impl !Freeze for VsdbBlockStore
impl RefUnwindSafe for VsdbBlockStore
impl Send for VsdbBlockStore
impl Sync for VsdbBlockStore
impl Unpin for VsdbBlockStore
impl UnsafeUnpin for VsdbBlockStore
impl UnwindSafe for VsdbBlockStore
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