Struct ckb_snapshot::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

source

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

source

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.

source

pub fn tip_header(&self) -> &HeaderView

Return reference of tip header

source

pub fn tip_number(&self) -> BlockNumber

Return tip header number

source

pub fn tip_hash(&self) -> Byte32

Return tip header hash

source

pub fn epoch_ext(&self) -> &EpochExt

Return current epoch information

source

pub fn consensus(&self) -> &Consensus

Return reference of Consensus

source

pub fn cloned_consensus(&self) -> Arc<Consensus>

Makes a clone of the Arc<Consensus>

source

pub fn proposals(&self) -> &ProposalView

Return reference of proposals view

source

pub fn total_difficulty(&self) -> &U256

Return current best chain total_difficulty

source

pub fn compute_versionbits(&self, parent: &HeaderView) -> Option<Version>

Returns what version a new block should use.

source

pub fn versionbits_active(&self, pos: DeploymentPos) -> bool

Returns specified softfork active or not

source

pub fn chain_root_mmr(&self, block_number: BlockNumber) -> ChainRootMMR<&Self>

Returns the chain root MMR for a provided block.

Trait Implementations§

source§

impl CellChecker for Snapshot

source§

fn is_live(&self, out_point: &OutPoint) -> Option<bool>

Returns true if the cell is live corresponding to specified out_point.
source§

impl CellProvider for Snapshot

source§

fn cell(&self, out_point: &OutPoint, eager_load: bool) -> CellStatus

TODO(doc): @quake
source§

impl ChainStore for Snapshot

source§

fn cache(&self) -> Option<&StoreCache>

Return cache reference
source§

fn get(&self, col: Col, key: &[u8]) -> Option<DBPinnableSlice<'_>>

Return the bytes associated with a key value and the given column family.
source§

fn freezer(&self) -> Option<&Freezer>

Return freezer reference
source§

fn get_iter(&self, col: Col, mode: IteratorMode<'_>) -> DBIter<'_>

Return an iterator over the database key-value pairs in the given column family.
source§

fn get_tip_header(&self) -> Option<HeaderView>

TODO(doc): @quake
source§

fn get_current_epoch_ext(&self) -> Option<EpochExt>

Gets current epoch ext
source§

fn borrow_as_data_loader(&self) -> BorrowedDataLoaderWrapper<'_, Self>

Return the borrowed data loader wrapper
source§

fn get_block(&self, h: &Byte32) -> Option<BlockView>

Get block by block header hash
source§

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>

Get block body by block header hash
source§

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>

Get all transaction-hashes in block body by block header hash
source§

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>

Get block uncles by block header hash
source§

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>

Get block ext by block header hash Read more
source§

fn get_block_hash(&self, number: u64) -> Option<Byte32>

Get block header hash by block number
source§

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

TODO(doc): @quake
source§

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)>

Get commit transaction and block hash by its hash
source§

fn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo>

TODO(doc): @quake
source§

fn get_transaction_with_info( &self, hash: &Byte32 ) -> Option<(TransactionView, TransactionInfo)>

Gets transaction and associated info with correspond hash
source§

fn have_cell(&self, out_point: &OutPoint) -> bool

Return whether cell is live
source§

fn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta>

Gets cell meta data with out_point
source§

fn get_cell_data(&self, out_point: &OutPoint) -> Option<(Bytes, Byte32)>

TODO(doc): @quake
source§

fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>

TODO(doc): @quake
source§

fn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt>

Gets epoch ext by epoch index
source§

fn get_epoch_index(&self, number: u64) -> Option<Byte32>

Gets epoch index by epoch number
source§

fn get_block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>

Gets epoch index by block hash
source§

fn get_block_epoch(&self, hash: &Byte32) -> Option<EpochExt>

TODO(doc): @quake
source§

fn is_uncle(&self, hash: &Byte32) -> bool

TODO(doc): @quake
source§

fn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView>

Gets header by uncle header hash
source§

fn block_exists(&self, hash: &Byte32) -> bool

TODO(doc): @quake
source§

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>

Gets latest built filter data block hash
source§

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>

Gets block filter hash by block hash
source§

fn get_packed_block(&self, hash: &Byte32) -> Option<Block>

Gets block bytes by block hash
source§

fn get_packed_block_header(&self, hash: &Byte32) -> Option<Header>

Gets block header bytes by block hash
source§

fn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest>

Gets a header digest.
source§

fn get_ancestor(&self, base: &Byte32, number: u64) -> Option<HeaderView>

Gets ancestor block header by a base block hash and number
source§

impl ConsensusProvider for Snapshot

source§

fn get_consensus(&self) -> &Consensus

Returns the Consensus.
source§

impl Debug for Snapshot

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Snapshot

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl HeaderChecker for Snapshot

source§

fn check_valid(&self, block_hash: &Byte32) -> Result<(), OutPointError>

Check if header in main chain
source§

impl HeaderFieldsProvider for Snapshot

source§

fn get_header_fields(&self, hash: &Byte32) -> Option<HeaderFields>

Get the header fields of the given block hash
source§

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 HeaderProvider for Snapshot

source§

fn get_header(&self, hash: &Byte32) -> Option<HeaderView>

Get the header of the given block hash
source§

impl MMRStore<HeaderDigest> for &Snapshot

source§

fn get_elem(&self, pos: u64) -> MMRResult<Option<HeaderDigest>>

source§

fn append(&mut self, _pos: u64, _elems: Vec<HeaderDigest>) -> MMRResult<()>

source§

impl PartialEq for Snapshot

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl VersionbitsIndexer for Snapshot

source§

fn block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32>

Gets epoch index by block hash
source§

fn epoch_ext(&self, index: &Byte32) -> Option<EpochExt>

Gets epoch ext by index
source§

fn block_header(&self, block_hash: &Byte32) -> Option<HeaderView>

Gets block header by block hash
source§

fn cellbase(&self, block_hash: &Byte32) -> Option<TransactionView>

Gets cellbase by block hash
source§

fn ancestor_epoch(&self, index: &Byte32, target: u64) -> Option<EpochExt>

Gets ancestor of specified epoch.
source§

impl Eq for Snapshot

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V