Snapshot

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

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

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: u64, ) -> MMR<HeaderDigest, MergeHeaderDigest, &Snapshot>

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: &'static str, 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: &'static str, mode: IteratorMode<'_>) -> DBIterator<'_>

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<(), Error>

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

impl Hash for Snapshot

Source§

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

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) -> Result<Option<HeaderDigest>, Error>

Source§

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

Source§

impl PartialEq for Snapshot

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,