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
sourceimpl 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
Trait Implementations
sourceimpl CellChecker for Snapshot
impl CellChecker for Snapshot
sourceimpl CellProvider for Snapshot
impl CellProvider for Snapshot
sourcefn cell(&self, out_point: &OutPoint, eager_load: bool) -> CellStatus
fn cell(&self, out_point: &OutPoint, eager_load: bool) -> CellStatus
TODO(doc): @quake
sourceimpl<'a> ChainStore<'a> for Snapshot
impl<'a> ChainStore<'a> for Snapshot
type Vector = DBPinnableSlice<'a>
type Vector = DBPinnableSlice<'a>
TODO(doc): @quake
sourcefn cache(&'a self) -> Option<&'a StoreCache>
fn cache(&'a self) -> Option<&'a StoreCache>
TODO(doc): @quake
sourcefn get(
&'a self,
col: &'static str,
key: &[u8]
) -> Option<<Snapshot as ChainStore<'a>>::Vector>
fn get(
&'a self,
col: &'static str,
key: &[u8]
) -> Option<<Snapshot as ChainStore<'a>>::Vector>
Return the bytes associated with a key value and the given column family.
sourcefn get_iter(&self, col: &'static str, mode: IteratorMode<'_>) -> DBIterator<'_>
fn get_iter(&self, col: &'static str, mode: IteratorMode<'_>) -> DBIterator<'_>
TODO(doc): @quake
sourcefn get_tip_header(&self) -> Option<HeaderView>
fn get_tip_header(&self) -> Option<HeaderView>
TODO(doc): @quake
sourcefn get_current_epoch_ext(&'a self) -> Option<EpochExt>
fn get_current_epoch_ext(&'a self) -> Option<EpochExt>
Gets current epoch ext
sourcefn as_data_provider(&'a self) -> DataLoaderWrapper<'a, Self>
fn as_data_provider(&'a self) -> DataLoaderWrapper<'a, Self>
Return the provider trait default implementation
sourcefn get_block_header(&'a self, hash: &Byte32) -> Option<HeaderView>
fn get_block_header(&'a self, hash: &Byte32) -> Option<HeaderView>
Get header by block header hash
sourcefn get_block_body(&'a self, hash: &Byte32) -> Vec<TransactionView, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn get_block_body(&'a self, hash: &Byte32) -> Vec<TransactionView, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get block body by block header hash
sourcefn get_unfrozen_block(&'a self, hash: &Byte32) -> Option<BlockView>
fn get_unfrozen_block(&'a self, hash: &Byte32) -> Option<BlockView>
Get unfrozen block from ky-store with given hash
sourcefn get_block_txs_hashes(&'a self, hash: &Byte32) -> Vec<Byte32, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn get_block_txs_hashes(&'a self, hash: &Byte32) -> Vec<Byte32, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get all transaction-hashes in block body by block header hash
sourcefn get_block_proposal_txs_ids(
&'a self,
hash: &Byte32
) -> Option<ProposalShortIdVec>
fn get_block_proposal_txs_ids(
&'a self,
hash: &Byte32
) -> Option<ProposalShortIdVec>
Get proposal short id by block header hash
sourcefn get_block_uncles(&'a self, hash: &Byte32) -> Option<UncleBlockVecView>
fn get_block_uncles(&'a self, hash: &Byte32) -> Option<UncleBlockVecView>
Get block uncles by block header hash
sourcefn get_block_extension(&'a self, hash: &Byte32) -> Option<Bytes>
fn get_block_extension(&'a self, hash: &Byte32) -> Option<Bytes>
Get block extension by block header hash
sourcefn get_block_ext(&'a self, block_hash: &Byte32) -> Option<BlockExt>
fn get_block_ext(&'a self, block_hash: &Byte32) -> Option<BlockExt>
Get block ext by block header hash
sourcefn get_block_hash(&'a self, number: u64) -> Option<Byte32>
fn get_block_hash(&'a self, number: u64) -> Option<Byte32>
Get block header hash by block number
sourcefn get_block_number(&'a self, hash: &Byte32) -> Option<u64>
fn get_block_number(&'a self, hash: &Byte32) -> Option<u64>
Get block number by block header hash
sourcefn is_main_chain(&'a self, hash: &Byte32) -> bool
fn is_main_chain(&'a self, hash: &Byte32) -> bool
TODO(doc): @quake
sourcefn transaction_exists(&'a self, hash: &Byte32) -> bool
fn transaction_exists(&'a self, hash: &Byte32) -> bool
Returns true if the transaction confirmed in main chain. Read more
sourcefn get_transaction(&'a self, hash: &Byte32) -> Option<(TransactionView, Byte32)>
fn get_transaction(&'a self, hash: &Byte32) -> Option<(TransactionView, Byte32)>
Get commit transaction and block hash by its hash
sourcefn get_transaction_info(&'a self, hash: &Byte32) -> Option<TransactionInfo>
fn get_transaction_info(&'a self, hash: &Byte32) -> Option<TransactionInfo>
TODO(doc): @quake
sourcefn get_transaction_with_info(
&'a self,
hash: &Byte32
) -> Option<(TransactionView, TransactionInfo)>
fn get_transaction_with_info(
&'a self,
hash: &Byte32
) -> Option<(TransactionView, TransactionInfo)>
Gets transaction and associated info with correspond hash
sourcefn get_cell(&'a self, out_point: &OutPoint) -> Option<CellMeta>
fn get_cell(&'a self, out_point: &OutPoint) -> Option<CellMeta>
Gets cell meta data with out_point
sourcefn get_cell_data_hash(&'a self, out_point: &OutPoint) -> Option<Byte32>
fn get_cell_data_hash(&'a self, out_point: &OutPoint) -> Option<Byte32>
TODO(doc): @quake
sourcefn get_epoch_ext(&'a self, hash: &Byte32) -> Option<EpochExt>
fn get_epoch_ext(&'a self, hash: &Byte32) -> Option<EpochExt>
Gets epoch ext by epoch index
sourcefn get_epoch_index(&'a self, number: u64) -> Option<Byte32>
fn get_epoch_index(&'a self, number: u64) -> Option<Byte32>
Gets epoch index by epoch number
sourcefn get_block_epoch_index(&'a self, block_hash: &Byte32) -> Option<Byte32>
fn get_block_epoch_index(&'a self, block_hash: &Byte32) -> Option<Byte32>
Gets epoch index by block hash
sourcefn get_block_epoch(&'a self, hash: &Byte32) -> Option<EpochExt>
fn get_block_epoch(&'a self, hash: &Byte32) -> Option<EpochExt>
TODO(doc): @quake
sourcefn get_uncle_header(&'a self, hash: &Byte32) -> Option<HeaderView>
fn get_uncle_header(&'a self, hash: &Byte32) -> Option<HeaderView>
Gets header by uncle header hash
sourcefn block_exists(&'a self, hash: &Byte32) -> bool
fn block_exists(&'a self, hash: &Byte32) -> bool
TODO(doc): @quake
sourcefn get_cellbase(&'a self, hash: &Byte32) -> Option<TransactionView>
fn get_cellbase(&'a self, hash: &Byte32) -> Option<TransactionView>
Gets cellbase by block hash
sourcefn get_packed_block(&'a self, hash: &Byte32) -> Option<Block>
fn get_packed_block(&'a self, hash: &Byte32) -> Option<Block>
TODO(doc): @quake
sourcefn get_packed_block_header(&'a self, hash: &Byte32) -> Option<Header>
fn get_packed_block_header(&'a self, hash: &Byte32) -> Option<Header>
TODO(doc): @quake
sourceimpl ConsensusProvider for Snapshot
impl ConsensusProvider for Snapshot
sourcefn get_consensus(&self) -> &Consensus
fn get_consensus(&self) -> &Consensus
Returns the Consensus.
sourceimpl HeaderChecker for Snapshot
impl HeaderChecker for Snapshot
sourcefn check_valid(&self, block_hash: &Byte32) -> Result<(), OutPointError>
fn check_valid(&self, block_hash: &Byte32) -> Result<(), OutPointError>
Check if header in main chain
sourceimpl HeaderProvider for Snapshot
impl HeaderProvider for Snapshot
sourcefn get_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_header(&self, hash: &Byte32) -> Option<HeaderView>
TODO(doc): @quake
fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
Return 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
Return past block median time, including the timestamp of the given one
Auto Trait Implementations
impl !RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl !UnwindSafe for Snapshot
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more