pub struct ShardStateStorage { /* private fields */ }Implementations§
Source§impl ShardStateStorage
impl ShardStateStorage
pub fn new( cells_db: CellsDb, block_handle_storage: Arc<BlockHandleStorage>, block_storage: Arc<BlockStorage>, block_connections: Arc<BlockConnectionStorage>, temp_file_storage: TempFileStorage, config: &CoreStorageConfig, ) -> Result<Arc<Self>>
pub fn metrics(&self) -> ShardStateStorageMetrics
pub fn min_ref_mc_state(&self) -> &MinRefMcStateTracker
pub fn cell_storage(&self) -> &Arc<CellStorage>
Sourcepub fn load_mc_block_id(&self, seqno: u32) -> Result<Option<BlockId>>
pub fn load_mc_block_id(&self, seqno: u32) -> Result<Option<BlockId>>
Find mc block id from db snapshot
pub async fn store_state_ignore_cache( &self, handle: &BlockHandle, state: &ShardStateStuff, hint: StoreStateHint, ) -> Result<()>
pub async fn store_state_root_ignore_cache( &self, handle: &BlockHandle, root: Cell, ref_mc_state_handle: RefMcStateHandle, hint: StoreStateHint, ) -> Result<()>
Sourcepub fn begin_store_next_state(
self: &Arc<Self>,
prev_handle: &BlockHandle,
next_handle: &BlockHandle,
merkle_update: &MerkleUpdate,
state: Option<ShardStateStuff>,
hint: StoreStateHint,
get_merkle_update: Option<Box<dyn Fn(&BlockId) -> Option<BlockInfoForApply> + Send + Sync + 'static>>,
) -> Result<InitiatedStoreState>
pub fn begin_store_next_state( self: &Arc<Self>, prev_handle: &BlockHandle, next_handle: &BlockHandle, merkle_update: &MerkleUpdate, state: Option<ShardStateStuff>, hint: StoreStateHint, get_merkle_update: Option<Box<dyn Fn(&BlockId) -> Option<BlockInfoForApply> + Send + Sync + 'static>>, ) -> Result<InitiatedStoreState>
Stores a state for the specified block pair of blocks using their merkle update and and optional state root.
§How does it work
State must be stored into CellsDb at least every store_shard_state_step
blocks (where it is forced to be 1 for masterchain). When we first initialize
the cache state for a shard we load the closest direct state for the target
with all required “virtual” states. After that we decide how should the next
state be stored (as “direct” or “virtual”) and store a spawned task into the cache.
pub async fn store_state_file( &self, block_id: &BlockId, boc: File, ) -> Result<HashBytes>
pub async fn store_state_bytes( &self, block_id: &BlockId, boc: Bytes, ) -> Result<HashBytes>
Sourcepub fn load_state(
&self,
ref_by_mc_seqno: u32,
block_id: &BlockId,
) -> impl Future<Output = Result<ShardStateStuff>>
pub fn load_state( &self, ref_by_mc_seqno: u32, block_id: &BlockId, ) -> impl Future<Output = Result<ShardStateStuff>>
Loads (or computes) a state for the specified block.
Sourcepub async fn load_state_ext<F>(
&self,
ref_by_mc_seqno: u32,
block_id: &BlockId,
hint: LoadStateHint,
get_merkle_update: F,
) -> Result<ShardStateStuff>
pub async fn load_state_ext<F>( &self, ref_by_mc_seqno: u32, block_id: &BlockId, hint: LoadStateHint, get_merkle_update: F, ) -> Result<ShardStateStuff>
Loads (or computes) a state for the specified block using an optional cache of yet unsaved blocks.
§How does it work
State is stored into CellsDb at least every store_shard_state_step
blocks. So when we load a state we must find some pivot state first and then
apply required intermediate merkle updates to it. We know the maximum
number of such updates so we can tell when the state is absent.
Merkle updates are loaded either using some external get_merkle_update
or from the storage.
§Store/load operation reuse
Saving states takes some time. So while loading a state we can attach to the original “saving future” and use its result. We will always attach to the “virtual” state future because otherwise we will be doing the same work. And we attach to “direct” states when their future is either complete, or we are deep enough in our apply routine.
pub fn load_state_root_hash(&self, block_id: &BlockId) -> Result<HashBytes>
pub fn load_state_root_hash_opt( &self, block_id: &BlockId, ) -> Result<Option<HashBytes>>
pub async fn remove_outdated_states(&self, mc_seqno: u32) -> Result<()>
Auto Trait Implementations§
impl Freeze for ShardStateStorage
impl !RefUnwindSafe for ShardStateStorage
impl Send for ShardStateStorage
impl Sync for ShardStateStorage
impl Unpin for ShardStateStorage
impl UnsafeUnpin for ShardStateStorage
impl !UnwindSafe for ShardStateStorage
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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