pub struct ConsensusSessionOwned { /* private fields */ }Expand description
An owned consensus session type which can be cloned and shared across threads.
See method spawn_blocking within for context on the usefulness of this type.
Please note - you must use ConsensusProxy type alias instead of this struct.
Implementations§
Source§impl ConsensusSessionOwned
impl ConsensusSessionOwned
pub fn new( session_guard: SessionOwnedReadGuard, consensus: DynConsensus, ) -> Self
pub fn new_without_session_guard(consensus: DynConsensus) -> Self
Sourcepub async fn spawn_blocking<F, R>(self, f: F) -> R
pub async fn spawn_blocking<F, R>(self, f: F) -> R
Uses tokio::task::spawn_blocking to run the provided consensus closure on a thread where blocking is acceptable.
Note that this function is only available on the owned session, and requires cloning the session. In fact this
function is the main motivation for a separate session type.
Source§impl ConsensusSessionOwned
impl ConsensusSessionOwned
pub fn validate_and_insert_block(&self, block: Block) -> BlockValidationFutures
pub fn validate_and_insert_block_batch( &self, batch: Vec<Block>, ) -> BlockProcessingBatch
pub fn validate_and_insert_trusted_block( &self, tb: TrustedBlock, ) -> BlockValidationFutures
pub fn calculate_transaction_compute_mass( &self, transaction: &Transaction, ) -> u64
pub fn calculate_transaction_storage_mass( &self, transaction: &MutableTransaction, ) -> Option<u64>
pub fn get_virtual_daa_score(&self) -> u64
pub fn get_virtual_bits(&self) -> u32
pub fn get_virtual_past_median_time(&self) -> u64
pub fn get_virtual_parents(&self) -> BlockHashSet
pub fn get_virtual_parents_len(&self) -> usize
pub async fn async_get_stats(&self) -> ConsensusStats
pub async fn async_get_virtual_merge_depth_root(&self) -> Option<Hash>
Sourcepub async fn async_get_virtual_merge_depth_blue_work_threshold(
&self,
) -> BlueWorkType
pub async fn async_get_virtual_merge_depth_blue_work_threshold( &self, ) -> BlueWorkType
Returns the BlueWork threshold at which blocks with lower or equal blue work are considered
to be un-mergeable by current virtual state.
(Note: in some rare cases when the node is unsynced the function might return zero as the threshold)
pub async fn async_get_sink(&self) -> Hash
pub async fn async_get_sink_timestamp(&self) -> u64
pub async fn async_get_current_block_color(&self, hash: Hash) -> Option<bool>
Sourcepub async fn async_get_source(&self) -> Hash
pub async fn async_get_source(&self) -> Hash
source refers to the earliest block from which the current node has full header & block data
pub async fn async_estimate_block_count(&self) -> BlockCount
Sourcepub async fn async_is_nearly_synced(&self) -> bool
pub async fn async_is_nearly_synced(&self) -> bool
Returns whether this consensus is considered synced or close to being synced.
This info is used to determine if it’s ok to use a block template from this node for mining purposes.
pub async fn async_get_virtual_chain_from_block( &self, low: Hash, chain_path_added_limit: Option<usize>, ) -> ConsensusResult<ChainPath>
pub async fn async_get_virtual_utxos( &self, from_outpoint: Option<TransactionOutpoint>, chunk_size: usize, skip_first: bool, ) -> Vec<(TransactionOutpoint, UtxoEntry)>
pub async fn async_get_tips(&self) -> Vec<Hash>
pub async fn async_get_tips_len(&self) -> usize
pub async fn async_is_chain_ancestor_of( &self, low: Hash, high: Hash, ) -> ConsensusResult<bool>
pub async fn async_get_hashes_between( &self, low: Hash, high: Hash, max_blocks: usize, ) -> ConsensusResult<(Vec<Hash>, Hash)>
pub async fn async_get_header(&self, hash: Hash) -> ConsensusResult<Arc<Header>>
pub async fn async_get_headers_selected_tip(&self) -> Hash
pub async fn async_get_chain_block_samples(&self) -> Vec<DaaScoreTimestamp>
Sourcepub async fn async_get_antipast_from_pov(
&self,
hash: Hash,
context: Hash,
max_traversal_allowed: Option<u64>,
) -> ConsensusResult<Vec<Hash>>
pub async fn async_get_antipast_from_pov( &self, hash: Hash, context: Hash, max_traversal_allowed: Option<u64>, ) -> ConsensusResult<Vec<Hash>>
Returns the antipast of block hash from the POV of context, i.e. antipast(hash) ∩ past(context).
Since this might be an expensive operation for deep blocks, we allow the caller to specify a limit
max_traversal_allowed on the maximum amount of blocks to traverse for obtaining the answer
Sourcepub async fn async_get_anticone(&self, hash: Hash) -> ConsensusResult<Vec<Hash>>
pub async fn async_get_anticone(&self, hash: Hash) -> ConsensusResult<Vec<Hash>>
Returns the anticone of block hash from the POV of virtual
pub async fn async_get_pruning_point_proof(&self) -> Arc<PruningPointProof> ⓘ
pub async fn async_create_virtual_selected_chain_block_locator( &self, low: Option<Hash>, high: Option<Hash>, ) -> ConsensusResult<Vec<Hash>>
pub async fn async_create_block_locator_from_pruning_point( &self, high: Hash, limit: usize, ) -> ConsensusResult<Vec<Hash>>
pub async fn async_pruning_point_headers(&self) -> Vec<Arc<Header>>
pub async fn async_get_pruning_point_anticone_and_trusted_data( &self, ) -> ConsensusResult<Arc<PruningPointTrustedData>>
pub async fn async_get_block(&self, hash: Hash) -> ConsensusResult<Block>
pub async fn async_get_block_even_if_header_only( &self, hash: Hash, ) -> ConsensusResult<Block>
pub async fn async_get_ghostdag_data( &self, hash: Hash, ) -> ConsensusResult<ExternalGhostdagData>
pub async fn async_get_block_children(&self, hash: Hash) -> Option<Vec<Hash>>
pub async fn async_get_block_parents( &self, hash: Hash, ) -> Option<Arc<Vec<Hash>>>
pub async fn async_get_block_status(&self, hash: Hash) -> Option<BlockStatus>
pub async fn async_get_block_acceptance_data( &self, hash: Hash, ) -> ConsensusResult<Arc<AcceptanceData>>
Sourcepub async fn async_get_blocks_acceptance_data(
&self,
hashes: Vec<Hash>,
merged_blocks_limit: Option<usize>,
) -> ConsensusResult<Vec<Arc<AcceptanceData>>>
pub async fn async_get_blocks_acceptance_data( &self, hashes: Vec<Hash>, merged_blocks_limit: Option<usize>, ) -> ConsensusResult<Vec<Arc<AcceptanceData>>>
Returns acceptance data for a set of blocks belonging to the selected parent chain.
See self::get_virtual_chain
pub async fn async_is_chain_block(&self, hash: Hash) -> ConsensusResult<bool>
pub async fn async_get_pruning_point_utxos( &self, expected_pruning_point: Hash, from_outpoint: Option<TransactionOutpoint>, chunk_size: usize, skip_first: bool, ) -> ConsensusResult<Vec<(TransactionOutpoint, UtxoEntry)>>
pub async fn async_get_missing_block_body_hashes( &self, high: Hash, ) -> ConsensusResult<Vec<Hash>>
pub async fn async_pruning_point(&self) -> Hash
pub async fn async_get_daa_window( &self, hash: Hash, ) -> ConsensusResult<Vec<Hash>>
pub async fn async_get_trusted_block_associated_ghostdag_data_block_hashes( &self, hash: Hash, ) -> ConsensusResult<Vec<Hash>>
pub async fn async_estimate_network_hashes_per_second( &self, start_hash: Option<Hash>, window_size: usize, ) -> ConsensusResult<u64>
pub async fn async_validate_pruning_points(&self) -> ConsensusResult<()>
pub async fn async_are_pruning_points_violating_finality( &self, pp_list: PruningPointsList, ) -> bool
pub async fn async_creation_timestamp(&self) -> u64
pub async fn async_finality_point(&self) -> Hash
Trait Implementations§
Source§impl Clone for ConsensusSessionOwned
impl Clone for ConsensusSessionOwned
Source§fn clone(&self) -> ConsensusSessionOwned
fn clone(&self) -> ConsensusSessionOwned
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ConsensusSessionOwned
impl !RefUnwindSafe for ConsensusSessionOwned
impl Send for ConsensusSessionOwned
impl Sync for ConsensusSessionOwned
impl Unpin for ConsensusSessionOwned
impl !UnwindSafe for ConsensusSessionOwned
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
Source§impl<T> CastFrom for Twhere
T: Any + 'static,
impl<T> CastFrom for Twhere
T: Any + 'static,
Source§fn ref_any(&self) -> &(dyn Any + 'static)
fn ref_any(&self) -> &(dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§fn mut_any(&mut self) -> &mut (dyn Any + 'static)
fn mut_any(&mut self) -> &mut (dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§impl<T> CastFromSync for T
impl<T> CastFromSync for T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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