Struct ckb_sync::SyncShared
source · [−]pub struct SyncShared { /* private fields */ }Expand description
Sync state shared between sync and relayer protocol
Implementations
sourcepub fn new(
shared: Shared,
sync_config: SyncConfig,
tx_relay_receiver: Receiver<TxVerificationResult>
) -> SyncShared
pub fn new(
shared: Shared,
sync_config: SyncConfig,
tx_relay_receiver: Receiver<TxVerificationResult>
) -> SyncShared
only use on test
sourcepub fn with_tmpdir<P>(
shared: Shared,
sync_config: SyncConfig,
tmpdir: Option<P>,
tx_relay_receiver: Receiver<TxVerificationResult>
) -> SyncShared where
P: AsRef<Path>,
pub fn with_tmpdir<P>(
shared: Shared,
sync_config: SyncConfig,
tmpdir: Option<P>,
tx_relay_receiver: Receiver<TxVerificationResult>
) -> SyncShared where
P: AsRef<Path>,
Generate a global sync state through configuration
Shared chain db/config
sourcepub fn active_chain(&self) -> ActiveChain
pub fn active_chain(&self) -> ActiveChain
Get snapshot with current chain
sourcepub fn insert_new_block(
&self,
chain: &ChainController,
block: Arc<BlockView>
) -> Result<bool, CKBError>
pub fn insert_new_block(
&self,
chain: &ChainController,
block: Arc<BlockView>
) -> Result<bool, CKBError>
Insert new block to chain store
sourcepub fn try_search_orphan_pool(&self, chain: &ChainController)
pub fn try_search_orphan_pool(&self, chain: &ChainController)
Try to find blocks from the orphan block pool that may no longer be orphan
sourcepub fn insert_valid_header(&self, peer: PeerIndex, header: &HeaderView)
pub fn insert_valid_header(&self, peer: PeerIndex, header: &HeaderView)
Sync a new valid header, try insert to sync state
sourcepub fn get_header_view(
&self,
hash: &Byte32,
store_first_opt: Option<bool>
) -> Option<HeaderView>
pub fn get_header_view(
&self,
hash: &Byte32,
store_first_opt: Option<bool>
) -> Option<HeaderView>
Get header view with hash
sourcepub fn is_stored(&self, hash: &Byte32) -> bool
pub fn is_stored(&self, hash: &Byte32) -> bool
Check whether block has been inserted to chain store
sourcepub fn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt>
pub fn get_epoch_ext(&self, hash: &Byte32) -> Option<EpochExt>
Get epoch ext by block hash
Trait Implementations
sourcefn clone(&self) -> SyncShared
fn clone(&self) -> SyncShared
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourcefn get_header(&self, hash: &Byte32) -> Option<HeaderView>
fn get_header(&self, hash: &Byte32) -> Option<HeaderView>
Get the header of the given block hash
sourcefn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)
Get timestamp and block_number of the corresponding block_hash, and hash of parent block
sourcefn 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
Get past block median time, including the timestamp of the given one
Auto Trait Implementations
Blanket Implementations
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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>
fn vzip(self) -> V
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