Struct ckb_store::ChainDB

source ·
pub struct ChainDB { /* private fields */ }
Expand description

A database of the chain store based on the RocksDB wrapper RocksDB

Implementations§

source§

impl ChainDB

source

pub fn new(db: RocksDB, config: StoreConfig) -> Self

Allocate a new ChainDB instance with the given config

source

pub fn new_with_freezer( db: RocksDB, freezer: Freezer, config: StoreConfig ) -> Self

Open new ChainDB with freezer instance

source

pub fn db(&self) -> &RocksDB

Return the inner RocksDB instance

source

pub fn into_inner(self) -> RocksDB

Converts self into a RocksDB

source

pub fn put_chain_spec_hash(&self, hash: &Byte32) -> Result<(), Error>

Store the chain spec hash

source

pub fn get_chain_spec_hash(&self) -> Option<Byte32>

Return the chain spec hash

source

pub fn get_migration_version(&self) -> Option<DBPinnableSlice<'_>>

Return the chain spec hash

source

pub fn begin_transaction(&self) -> StoreTransaction

Set this snapshot at start of transaction

source

pub fn get_snapshot(&self) -> StoreSnapshot

Return StoreSnapshot

source

pub fn new_write_batch(&self) -> StoreWriteBatch

Construct StoreWriteBatch with default option.

source

pub fn write(&self, write_batch: &StoreWriteBatch) -> Result<(), Error>

Write batch into chain db.

source

pub fn write_sync(&self, write_batch: &StoreWriteBatch) -> Result<(), Error>

write options set_sync = true

see RocksDB::write_sync.

source

pub fn compact_range( &self, col: Col, start: Option<&[u8]>, end: Option<&[u8]> ) -> Result<(), Error>

Force the data to go through the compaction in order to consolidate it

see RocksDB::compact_range.

source

pub fn init(&self, consensus: &Consensus) -> Result<(), Error>

TODO(doc): @quake

Trait Implementations§

source§

impl ChainStore for ChainDB

source§

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

Return cache reference
source§

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

Return freezer 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 get_iter(&self, col: Col, mode: IteratorMode<'_>) -> DBIter<'_>

Return an iterator over the database key-value pairs in the given column family.
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: BlockNumber) -> Option<Byte32>

Get block header hash by block number
source§

fn get_block_number(&self, hash: &Byte32) -> Option<BlockNumber>

Get block number by block header hash
source§

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

TODO(doc): @quake
source§

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

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_current_epoch_ext(&self) -> Option<EpochExt>

Gets current epoch ext
source§

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

Gets epoch ext by epoch index
source§

fn get_epoch_index(&self, number: EpochNumber) -> 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: BlockNumber) -> Option<HeaderView>

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

impl Clone for ChainDB

source§

fn clone(&self) -> ChainDB

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl VersionbitsIndexer for ChainDB

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.

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
§

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

§

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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