Trait ckb_store::ChainStore
source · pub trait ChainStore: Send + Sync + Sized {
Show 42 methods
// Required methods
fn cache(&self) -> Option<&StoreCache>;
fn freezer(&self) -> Option<&Freezer>;
fn get(&self, col: Col, key: &[u8]) -> Option<DBPinnableSlice<'_>>;
fn get_iter(&self, col: Col, mode: IteratorMode<'_>) -> DBIter<'_>;
// Provided methods
fn borrow_as_data_loader(&self) -> BorrowedDataLoaderWrapper<'_, Self> { ... }
fn get_block(&self, h: &Byte32) -> Option<BlockView> { ... }
fn get_block_header(&self, hash: &Byte32) -> Option<HeaderView> { ... }
fn get_block_body(&self, hash: &Byte32) -> Vec<TransactionView> { ... }
fn get_unfrozen_block(&self, hash: &Byte32) -> Option<BlockView> { ... }
fn get_block_txs_hashes(&self, hash: &Byte32) -> Vec<Byte32> { ... }
fn get_block_proposal_txs_ids(
&self,
hash: &Byte32
) -> Option<ProposalShortIdVec> { ... }
fn get_block_uncles(&self, hash: &Byte32) -> Option<UncleBlockVecView> { ... }
fn get_block_extension(&self, hash: &Byte32) -> Option<Bytes> { ... }
fn get_block_ext(&self, block_hash: &Byte32) -> Option<BlockExt> { ... }
fn get_block_hash(&self, number: BlockNumber) -> Option<Byte32> { ... }
fn get_block_number(&self, hash: &Byte32) -> Option<BlockNumber> { ... }
fn is_main_chain(&self, hash: &Byte32) -> bool { ... }
fn get_tip_header(&self) -> Option<HeaderView> { ... }
fn transaction_exists(&self, hash: &Byte32) -> bool { ... }
fn get_transaction(
&self,
hash: &Byte32
) -> Option<(TransactionView, Byte32)> { ... }
fn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo> { ... }
fn get_transaction_with_info(
&self,
hash: &Byte32
) -> Option<(TransactionView, TransactionInfo)> { ... }
fn have_cell(&self, out_point: &OutPoint) -> bool { ... }
fn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta> { ... }
fn get_cell_data(&self, out_point: &OutPoint) -> Option<(Bytes, Byte32)> { ... }
fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32> { ... }
fn get_current_epoch_ext(&self) -> Option<EpochExt> { ... }
fn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt> { ... }
fn get_epoch_index(&self, number: EpochNumber) -> Option<Byte32> { ... }
fn get_block_epoch_index(&self, block_hash: &Byte32) -> Option<Byte32> { ... }
fn get_block_epoch(&self, hash: &Byte32) -> Option<EpochExt> { ... }
fn is_uncle(&self, hash: &Byte32) -> bool { ... }
fn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView> { ... }
fn block_exists(&self, hash: &Byte32) -> bool { ... }
fn get_cellbase(&self, hash: &Byte32) -> Option<TransactionView> { ... }
fn get_latest_built_filter_data_block_hash(&self) -> Option<Byte32> { ... }
fn get_block_filter(&self, hash: &Byte32) -> Option<Bytes> { ... }
fn get_block_filter_hash(&self, hash: &Byte32) -> Option<Byte32> { ... }
fn get_packed_block(&self, hash: &Byte32) -> Option<Block> { ... }
fn get_packed_block_header(&self, hash: &Byte32) -> Option<Header> { ... }
fn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest> { ... }
fn get_ancestor(
&self,
base: &Byte32,
number: BlockNumber
) -> Option<HeaderView> { ... }
}
Expand description
The ChainStore
trait provides chain data store interface
Required Methods§
sourcefn cache(&self) -> Option<&StoreCache>
fn cache(&self) -> Option<&StoreCache>
Return cache reference
Provided Methods§
sourcefn borrow_as_data_loader(&self) -> BorrowedDataLoaderWrapper<'_, Self>
fn borrow_as_data_loader(&self) -> BorrowedDataLoaderWrapper<'_, Self>
Return the borrowed data loader wrapper
sourcefn get_block_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_block_header(&self, hash: &Byte32) -> Option<HeaderView>
Get header by block header hash
sourcefn get_block_body(&self, hash: &Byte32) -> Vec<TransactionView>
fn get_block_body(&self, hash: &Byte32) -> Vec<TransactionView>
Get block body by block header hash
sourcefn 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
sourcefn get_block_txs_hashes(&self, hash: &Byte32) -> Vec<Byte32>
fn get_block_txs_hashes(&self, hash: &Byte32) -> Vec<Byte32>
Get all transaction-hashes in block body by block header hash
sourcefn 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
sourcefn get_block_uncles(&self, hash: &Byte32) -> Option<UncleBlockVecView>
fn get_block_uncles(&self, hash: &Byte32) -> Option<UncleBlockVecView>
Get block uncles by block header hash
sourcefn get_block_extension(&self, hash: &Byte32) -> Option<Bytes>
fn get_block_extension(&self, hash: &Byte32) -> Option<Bytes>
Get block extension by block header hash
sourcefn 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
Since v0.106, BlockExt
added two option fields, so we have to use compatibility mode to read
sourcefn get_block_hash(&self, number: BlockNumber) -> Option<Byte32>
fn get_block_hash(&self, number: BlockNumber) -> Option<Byte32>
Get block header hash by block number
sourcefn get_block_number(&self, hash: &Byte32) -> Option<BlockNumber>
fn get_block_number(&self, hash: &Byte32) -> Option<BlockNumber>
Get block number by block header hash
sourcefn is_main_chain(&self, hash: &Byte32) -> bool
fn is_main_chain(&self, hash: &Byte32) -> bool
TODO(doc): @quake
sourcefn get_tip_header(&self) -> Option<HeaderView>
fn get_tip_header(&self) -> Option<HeaderView>
TODO(doc): @quake
sourcefn transaction_exists(&self, hash: &Byte32) -> bool
fn transaction_exists(&self, hash: &Byte32) -> bool
Returns true if the transaction confirmed in main chain.
This function is base on transaction index COLUMN_TRANSACTION_INFO
.
Current release maintains a full index of historical transaction by default, this may be changed in future
sourcefn 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
sourcefn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo>
fn get_transaction_info(&self, hash: &Byte32) -> Option<TransactionInfo>
TODO(doc): @quake
sourcefn 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
sourcefn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta>
fn get_cell(&self, out_point: &OutPoint) -> Option<CellMeta>
Gets cell meta data with out_point
sourcefn get_cell_data(&self, out_point: &OutPoint) -> Option<(Bytes, Byte32)>
fn get_cell_data(&self, out_point: &OutPoint) -> Option<(Bytes, Byte32)>
TODO(doc): @quake
sourcefn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>
fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>
TODO(doc): @quake
sourcefn get_current_epoch_ext(&self) -> Option<EpochExt>
fn get_current_epoch_ext(&self) -> Option<EpochExt>
Gets current epoch ext
sourcefn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt>
fn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt>
Gets epoch ext by epoch index
sourcefn get_epoch_index(&self, number: EpochNumber) -> Option<Byte32>
fn get_epoch_index(&self, number: EpochNumber) -> Option<Byte32>
Gets epoch index by epoch number
sourcefn 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
sourcefn get_block_epoch(&self, hash: &Byte32) -> Option<EpochExt>
fn get_block_epoch(&self, hash: &Byte32) -> Option<EpochExt>
TODO(doc): @quake
sourcefn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_uncle_header(&self, hash: &Byte32) -> Option<HeaderView>
Gets header by uncle header hash
sourcefn block_exists(&self, hash: &Byte32) -> bool
fn block_exists(&self, hash: &Byte32) -> bool
TODO(doc): @quake
sourcefn get_cellbase(&self, hash: &Byte32) -> Option<TransactionView>
fn get_cellbase(&self, hash: &Byte32) -> Option<TransactionView>
Gets cellbase by block hash
sourcefn 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
sourcefn get_block_filter(&self, hash: &Byte32) -> Option<Bytes>
fn get_block_filter(&self, hash: &Byte32) -> Option<Bytes>
Gets block filter data by block hash
sourcefn 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
sourcefn get_packed_block(&self, hash: &Byte32) -> Option<Block>
fn get_packed_block(&self, hash: &Byte32) -> Option<Block>
Gets block bytes by block hash
sourcefn get_packed_block_header(&self, hash: &Byte32) -> Option<Header>
fn get_packed_block_header(&self, hash: &Byte32) -> Option<Header>
Gets block header bytes by block hash
sourcefn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest>
fn get_header_digest(&self, position_u64: u64) -> Option<HeaderDigest>
Gets a header digest.
sourcefn get_ancestor(&self, base: &Byte32, number: BlockNumber) -> Option<HeaderView>
fn get_ancestor(&self, base: &Byte32, number: BlockNumber) -> Option<HeaderView>
Gets ancestor block header by a base block hash and number