pub struct BlockStore {
pub store_path: String,
/* private fields */
}Fields§
§store_path: StringImplementations§
Source§impl BlockStore
impl BlockStore
pub fn new_empty(path: &str) -> Self
Sourcepub fn add_block(
&self,
block: Block,
diffs: UTXODiff,
) -> Result<(), BlockStoreError>
pub fn add_block( &self, block: Block, diffs: UTXODiff, ) -> Result<(), BlockStoreError>
Adds a block, writing it to disk, updating block lookup and current height WARNING: block MUST be valid beforehand!
pub fn pop_block(&self) -> Result<(), BlockStoreError>
Sourcepub fn get_height(&self) -> usize
pub fn get_height(&self) -> usize
Gets current block height (count of all blocks)
Sourcepub fn get_last_block_hash(&self) -> Hash
pub fn get_last_block_hash(&self) -> Hash
Gets last added block hash (GENESIS_PREVIOUS_BLOCK_HASH if height = 0)
Sourcepub fn get_last_block(&self) -> Option<Block>
pub fn get_last_block(&self) -> Option<Block>
Gets last added block
Sourcepub fn get_block_by_height(&self, height: usize) -> Option<Block>
pub fn get_block_by_height(&self, height: usize) -> Option<Block>
Gets block referenced by it’s height
Sourcepub fn get_block_by_hash(&self, hash: Hash) -> Option<Block>
pub fn get_block_by_hash(&self, hash: Hash) -> Option<Block>
Gets block referenced by it’s hash
Sourcepub fn get_block_hash_by_height(&self, height: usize) -> Option<Hash>
pub fn get_block_hash_by_height(&self, height: usize) -> Option<Hash>
Gets block hash referenced by it’s height
Sourcepub fn get_block_height_by_hash(&self, hash: Hash) -> Option<usize>
pub fn get_block_height_by_hash(&self, hash: Hash) -> Option<usize>
Gets block height referenced by it’s hash
pub fn get_last_utxo_diffs(&self) -> Option<UTXODiff>
Sourcepub fn get_utxo_diffs_by_height(&self, height: usize) -> Option<UTXODiff>
pub fn get_utxo_diffs_by_height(&self, height: usize) -> Option<UTXODiff>
Gets UTXO diffs by block height
Sourcepub fn get_utxo_diffs_by_hash(&self, hash: Hash) -> Option<UTXODiff>
pub fn get_utxo_diffs_by_hash(&self, hash: Hash) -> Option<UTXODiff>
Gets UTXO diffs by block hash
pub fn get_transaction(&self, tx_id: TransactionId) -> Option<Transaction>
pub fn get_transaction_and_info( &self, tx_id: TransactionId, ) -> Option<TransactionAndInfo>
pub fn iter_blocks( &self, ) -> impl DoubleEndedIterator<Item = Result<Block, BlockStoreError>> + '_
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for BlockStore
impl<'__de, __Context> BorrowDecode<'__de, __Context> for BlockStore
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl Clone for BlockStore
impl Clone for BlockStore
Source§impl Debug for BlockStore
impl Debug for BlockStore
Source§impl<__Context> Decode<__Context> for BlockStore
impl<__Context> Decode<__Context> for BlockStore
Auto Trait Implementations§
impl !Freeze for BlockStore
impl RefUnwindSafe for BlockStore
impl Send for BlockStore
impl Sync for BlockStore
impl Unpin for BlockStore
impl UnwindSafe for BlockStore
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