Struct ckb_shared::Snapshot
source · pub struct Snapshot { /* private fields */ }Expand description
A snapshot captures a point-in-time view of the DB at the time it’s created
Implementations§
source§impl Snapshot
impl Snapshot
sourcepub fn new(
tip_header: HeaderView,
total_difficulty: U256,
epoch_ext: EpochExt,
store: StoreSnapshot,
proposals: ProposalView,
consensus: Arc<Consensus>
) -> Snapshot
pub fn new( tip_header: HeaderView, total_difficulty: U256, epoch_ext: EpochExt, store: StoreSnapshot, proposals: ProposalView, consensus: Arc<Consensus> ) -> Snapshot
New snapshot created after tip change
sourcepub fn refresh(&self, store: StoreSnapshot) -> Snapshot
pub fn refresh(&self, store: StoreSnapshot) -> Snapshot
Refreshing on block commit is necessary operation, even tip remains unchanged. when node relayed compact block,if some uncles were not available from receiver’s local sources, in GetBlockTransactions/BlockTransactions roundtrip, node will need access block data of uncles.
sourcepub fn tip_header(&self) -> &HeaderView
pub fn tip_header(&self) -> &HeaderView
Return reference of tip header
sourcepub fn tip_number(&self) -> u64
pub fn tip_number(&self) -> u64
Return tip header number
sourcepub fn cloned_consensus(&self) -> Arc<Consensus>
pub fn cloned_consensus(&self) -> Arc<Consensus>
Makes a clone of the Arc<Consensus>
sourcepub fn proposals(&self) -> &ProposalView
pub fn proposals(&self) -> &ProposalView
Return reference of proposals view
sourcepub fn total_difficulty(&self) -> &U256
pub fn total_difficulty(&self) -> &U256
Return current best chain total_difficulty
sourcepub fn compute_versionbits(&self, parent: &HeaderView) -> Option<u32>
pub fn compute_versionbits(&self, parent: &HeaderView) -> Option<u32>
Returns what version a new block should use.
sourcepub fn versionbits_active(&self, pos: DeploymentPos) -> bool
pub fn versionbits_active(&self, pos: DeploymentPos) -> bool
Returns specified softfork active or not
sourcepub fn chain_root_mmr(
&self,
block_number: u64
) -> MMR<HeaderDigest, MergeHeaderDigest, &Snapshot>
pub fn chain_root_mmr( &self, block_number: u64 ) -> MMR<HeaderDigest, MergeHeaderDigest, &Snapshot>
Returns the chain root MMR for a provided block.
Trait Implementations§
source§impl CellChecker for Snapshot
impl CellChecker for Snapshot
source§impl CellProvider for Snapshot
impl CellProvider for Snapshot
source§impl ChainStore for Snapshot
impl ChainStore for Snapshot
source§fn cache(&self) -> Option<&StoreCache>
fn cache(&self) -> Option<&StoreCache>
TODO(doc): @quake
source§fn get(&self, col: &'static str, key: &[u8]) -> Option<DBPinnableSlice<'_>>
fn get(&self, col: &'static str, key: &[u8]) -> Option<DBPinnableSlice<'_>>
Return the bytes associated with a key value and the given column family.
source§fn get_iter(&self, col: &'static str, mode: IteratorMode<'_>) -> DBIterator<'_>
fn get_iter(&self, col: &'static str, mode: IteratorMode<'_>) -> DBIterator<'_>
TODO(doc): @quake
source§fn get_tip_header(&self) -> Option<HeaderView>
fn get_tip_header(&self) -> Option<HeaderView>
TODO(doc): @quake
source§fn get_current_epoch_ext(&self) -> Option<EpochExt>
fn get_current_epoch_ext(&self) -> Option<EpochExt>
Gets current epoch ext
source§fn as_data_provider(&self) -> DataLoaderWrapper<'_, Self>
fn as_data_provider(&self) -> DataLoaderWrapper<'_, Self>
Return the provider trait default implementation
source§fn get_block_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_block_header(&self, hash: &Byte32) -> Option<HeaderView>
Get header by block header hash
source§fn get_block_body(&self, hash: &Byte32) -> Vec<TransactionView, Global> ⓘ
fn get_block_body(&self, hash: &Byte32) -> Vec<TransactionView, Global> ⓘ
Get block body by block header hash
source§fn get_unfrozen_block(&self, hash: &Byte32) -> Option<BlockView>
fn get_unfrozen_block(&self, hash: &Byte32) -> Option<BlockView>
Get unfrozen block from ky-store with given hash
source§fn get_block_txs_hashes(&self, hash: &Byte32) -> Vec<Byte32, Global> ⓘ
fn get_block_txs_hashes(&self, hash: &Byte32) -> Vec<Byte32, Global> ⓘ
Get all transaction-hashes in block body by block header hash
source§fn get_block_proposal_txs_ids(&self, hash: &Byte32) -> Option<ProposalShortIdVec>
fn get_block_proposal_txs_ids(&self, hash: &Byte32) -> Option<ProposalShortIdVec>
Get proposal short id by block header hash
source§fn get_block_uncles(&self, hash: &Byte32) -> Option<UncleBlockVecView>
fn get_block_uncles(&self, hash: &Byte32) -> Option<UncleBlockVecView>
Get block uncles by block header hash
source§fn get_block_extension(&self, hash: &Byte32) -> Option<Bytes>
fn get_block_extension(&self, hash: &Byte32) -> Option<Bytes>
Get block extension by block header hash
source§fn get_block_ext(&self, block_hash: &Byte32) -> Option<BlockExt>
fn get_block_ext(&self, block_hash: &Byte32) -> Option<BlockExt>
Get block ext by block header hash Read more
source§fn get_block_number(&self, hash: &Byte32) -> Option<u64>
fn get_block_number(&self, hash: &Byte32) -> Option<u64>
Get block number by block header hash
source§fn is_main_chain(&self, hash: &Byte32) -> bool
fn is_main_chain(&self, hash: &Byte32) -> bool
TODO(doc): @quake
source§fn transaction_exists(&self, hash: &Byte32) -> bool
fn transaction_exists(&self, hash: &Byte32) -> bool
Returns true if the transaction confirmed in main chain. Read more
source§fn get_transaction(&self, hash: &Byte32) -> Option<(TransactionView, Byte32)>
fn get_transaction(&self, hash: &Byte32) -> Option<(TransactionView, Byte32)>
Get commit transaction and block hash by its hash
source§fn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo>
fn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo>
TODO(doc): @quake
source§fn get_transaction_with_info(
&self,
hash: &Byte32
) -> Option<(TransactionView, TransactionInfo)>
fn get_transaction_with_info( &self, hash: &Byte32 ) -> Option<(TransactionView, TransactionInfo)>
Gets transaction and associated info with correspond hash
source§fn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta>
fn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta>
Gets cell meta data with out_point
source§fn get_block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>
fn get_block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>
Gets epoch index by block hash
source§fn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView>
Gets header by uncle header hash
source§fn block_exists(&self, hash: &Byte32) -> bool
fn block_exists(&self, hash: &Byte32) -> bool
TODO(doc): @quake
source§fn get_cellbase(&self, hash: &Byte32) -> Option<TransactionView>
fn get_cellbase(&self, hash: &Byte32) -> Option<TransactionView>
Gets cellbase by block hash
source§fn get_latest_built_filter_data_block_hash(&self) -> Option<Byte32>
fn get_latest_built_filter_data_block_hash(&self) -> Option<Byte32>
Gets latest built filter data block hash
source§fn get_block_filter(&self, hash: &Byte32) -> Option<Bytes>
fn get_block_filter(&self, hash: &Byte32) -> Option<Bytes>
Gets block filter data by block hash
source§fn get_block_filter_hash(&self, hash: &Byte32) -> Option<Byte32>
fn get_block_filter_hash(&self, hash: &Byte32) -> Option<Byte32>
Gets block filter hash by block hash
source§fn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest>
fn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest>
Gets a header digest.
source§impl ConsensusProvider for Snapshot
impl ConsensusProvider for Snapshot
source§fn get_consensus(&self) -> &Consensus
fn get_consensus(&self) -> &Consensus
Returns the
Consensus.source§impl HeaderChecker for Snapshot
impl HeaderChecker for Snapshot
source§fn check_valid(&self, block_hash: &Byte32) -> Result<(), OutPointError>
fn check_valid(&self, block_hash: &Byte32) -> Result<(), OutPointError>
Check if header in main chain
source§impl HeaderProvider for Snapshot
impl HeaderProvider for Snapshot
source§fn get_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_header(&self, hash: &Byte32) -> Option<HeaderView>
Get the header of the given block hash
§fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
Get timestamp and block_number of the corresponding block_hash, and hash of parent block
§fn block_median_time(&self, block_hash: &Byte32, median_block_count: usize) -> u64
fn block_median_time(&self, block_hash: &Byte32, median_block_count: usize) -> u64
Get past block median time, including the timestamp of the given one
source§impl MMRStore<HeaderDigest> for &Snapshot
impl MMRStore<HeaderDigest> for &Snapshot
source§impl PartialEq<Snapshot> for Snapshot
impl PartialEq<Snapshot> for Snapshot
source§impl VersionbitsIndexer for Snapshot
impl VersionbitsIndexer for Snapshot
source§fn block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>
fn block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>
Gets epoch index by block hash
source§fn block_header(&self, block_hash: &Byte32) -> Option<HeaderView>
fn block_header(&self, block_hash: &Byte32) -> Option<HeaderView>
Gets block header by block hash