pub struct InMemoryBlockStore { /* private fields */ }Expand description
In-memory implementation of BlockStore using HashMap and RwLock
Implementations§
Source§impl InMemoryBlockStore
impl InMemoryBlockStore
Sourcepub async fn init_with_genesis(&self, genesis: Block)
pub async fn init_with_genesis(&self, genesis: Block)
Initialize with genesis block
Trait Implementations§
Source§impl BlockStore for InMemoryBlockStore
impl BlockStore for InMemoryBlockStore
Source§fn store_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block,
height: u32,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block,
height: u32,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stores a block in persistent storage. Read more
Source§fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<Block>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<Block>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves a block by its hash. Read more
Source§fn get_block_header<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<BlockHeader>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block_header<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<BlockHeader>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves a block header by its hash. Read more
Source§fn has_block<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_block<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Checks if a block exists in storage. Read more
Source§fn get_best_block_hash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BlockHash, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_best_block_hash<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BlockHash, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the hash of the best (most-work) block in the chain. Read more
Source§fn get_block_height<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<u32>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block_height<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<u32>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets the height of a block. Read more
Auto Trait Implementations§
impl Freeze for InMemoryBlockStore
impl !RefUnwindSafe for InMemoryBlockStore
impl Send for InMemoryBlockStore
impl Sync for InMemoryBlockStore
impl Unpin for InMemoryBlockStore
impl UnsafeUnpin for InMemoryBlockStore
impl !UnwindSafe for InMemoryBlockStore
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