pub struct FlatChainStore { /* private fields */ }flat-chainstore only.Expand description
The main struct that holds all the context for our flat chain store
This struct is kept in memory, and it holds multiple memory maps that may or may not be in RAM right now. All functions in the impl block are inherently unsafe, since we’re dealing with raw pointers and memory maps. We need to be very careful with them. All methods should be carefully tested and reviewed. This struct is not thread-safe, and it’s not meant to be used in multi-threaded environments without proper synchronization.
We only ever expect one chainstate to hold a FlatChainStore at a time. You can then use that chainstate to interact with the chainstore, even in a multi-threaded environment.
Implementations§
Source§impl FlatChainStore
impl FlatChainStore
Sourcepub fn new(config: FlatChainStoreConfig) -> Result<Self, FlatChainstoreError>
pub fn new(config: FlatChainStoreConfig) -> Result<Self, FlatChainstoreError>
Opens a new storage. If it already exists, just load. If not, create a new one
Sourcepub fn compute_checksum(&self) -> DbCheckSum
pub fn compute_checksum(&self) -> DbCheckSum
Computes the XXH3-64 checksum for our database
Trait Implementations§
Source§impl ChainStore for FlatChainStore
impl ChainStore for FlatChainStore
type Error = FlatChainstoreError
Source§fn check_integrity(&self) -> Result<(), Self::Error>
fn check_integrity(&self) -> Result<(), Self::Error>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Source§fn save_roots_for_block(
&mut self,
roots: Vec<u8>,
height: u32,
) -> Result<(), Self::Error>
fn save_roots_for_block( &mut self, roots: Vec<u8>, height: u32, ) -> Result<(), Self::Error>
Source§fn load_roots_for_block(
&mut self,
height: u32,
) -> Result<Option<Vec<u8>>, Self::Error>
fn load_roots_for_block( &mut self, height: u32, ) -> Result<Option<Vec<u8>>, Self::Error>
Source§fn get_header(
&self,
block_hash: &BlockHash,
) -> Result<Option<DiskBlockHeader>, Self::Error>
fn get_header( &self, block_hash: &BlockHash, ) -> Result<Option<DiskBlockHeader>, Self::Error>
Source§fn get_header_by_height(
&self,
height: u32,
) -> Result<Option<DiskBlockHeader>, Self::Error>
fn get_header_by_height( &self, height: u32, ) -> Result<Option<DiskBlockHeader>, Self::Error>
Source§fn save_height(&mut self, height: &BestChain) -> Result<(), Self::Error>
fn save_height(&mut self, height: &BestChain) -> Result<(), Self::Error>
Source§fn save_header(&mut self, header: &DiskBlockHeader) -> Result<(), Self::Error>
fn save_header(&mut self, header: &DiskBlockHeader) -> Result<(), Self::Error>
Auto Trait Implementations§
impl !Freeze for FlatChainStore
impl RefUnwindSafe for FlatChainStore
impl Send for FlatChainStore
impl Sync for FlatChainStore
impl Unpin for FlatChainStore
impl UnwindSafe for FlatChainStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more