ConsensusSessionOwned

Struct ConsensusSessionOwned 

Source
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

Source

pub fn new( session_guard: SessionOwnedReadGuard, consensus: DynConsensus, ) -> Self

Source

pub fn new_without_session_guard(consensus: DynConsensus) -> Self

Source

pub async fn spawn_blocking<F, R>(self, f: F) -> R
where F: FnOnce(&dyn ConsensusApi) -> R + Send + 'static, R: Send + 'static,

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

Source

pub fn validate_and_insert_block(&self, block: Block) -> BlockValidationFutures

Source

pub fn validate_and_insert_block_batch( &self, batch: Vec<Block>, ) -> BlockProcessingBatch

Source

pub fn validate_and_insert_trusted_block( &self, tb: TrustedBlock, ) -> BlockValidationFutures

Source

pub fn calculate_transaction_compute_mass( &self, transaction: &Transaction, ) -> u64

Source

pub fn calculate_transaction_storage_mass( &self, transaction: &MutableTransaction, ) -> Option<u64>

Source

pub fn get_virtual_daa_score(&self) -> u64

Source

pub fn get_virtual_bits(&self) -> u32

Source

pub fn get_virtual_past_median_time(&self) -> u64

Source

pub fn get_virtual_parents(&self) -> BlockHashSet

Source

pub fn get_virtual_parents_len(&self) -> usize

Source

pub async fn async_get_stats(&self) -> ConsensusStats

Source

pub async fn async_get_virtual_merge_depth_root(&self) -> Option<Hash>

Source

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)

Source

pub async fn async_get_sink(&self) -> Hash

Source

pub async fn async_get_sink_timestamp(&self) -> u64

Source

pub async fn async_get_current_block_color(&self, hash: Hash) -> Option<bool>

Source

pub async fn async_get_source(&self) -> Hash

source refers to the earliest block from which the current node has full header & block data

Source

pub async fn async_estimate_block_count(&self) -> BlockCount

Source

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.

Source

pub async fn async_get_virtual_chain_from_block( &self, low: Hash, chain_path_added_limit: Option<usize>, ) -> ConsensusResult<ChainPath>

Source

pub async fn async_get_virtual_utxos( &self, from_outpoint: Option<TransactionOutpoint>, chunk_size: usize, skip_first: bool, ) -> Vec<(TransactionOutpoint, UtxoEntry)>

Source

pub async fn async_get_tips(&self) -> Vec<Hash>

Source

pub async fn async_get_tips_len(&self) -> usize

Source

pub async fn async_is_chain_ancestor_of( &self, low: Hash, high: Hash, ) -> ConsensusResult<bool>

Source

pub async fn async_get_hashes_between( &self, low: Hash, high: Hash, max_blocks: usize, ) -> ConsensusResult<(Vec<Hash>, Hash)>

Source

pub async fn async_get_header(&self, hash: Hash) -> ConsensusResult<Arc<Header>>

Source

pub async fn async_get_headers_selected_tip(&self) -> Hash

Source

pub async fn async_get_chain_block_samples(&self) -> Vec<DaaScoreTimestamp>

Source

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

Source

pub async fn async_get_anticone(&self, hash: Hash) -> ConsensusResult<Vec<Hash>>

Returns the anticone of block hash from the POV of virtual

Source

pub async fn async_get_pruning_point_proof(&self) -> Arc<PruningPointProof>

Source

pub async fn async_create_virtual_selected_chain_block_locator( &self, low: Option<Hash>, high: Option<Hash>, ) -> ConsensusResult<Vec<Hash>>

Source

pub async fn async_create_block_locator_from_pruning_point( &self, high: Hash, limit: usize, ) -> ConsensusResult<Vec<Hash>>

Source

pub async fn async_pruning_point_headers(&self) -> Vec<Arc<Header>>

Source

pub async fn async_get_pruning_point_anticone_and_trusted_data( &self, ) -> ConsensusResult<Arc<PruningPointTrustedData>>

Source

pub async fn async_get_block(&self, hash: Hash) -> ConsensusResult<Block>

Source

pub async fn async_get_block_even_if_header_only( &self, hash: Hash, ) -> ConsensusResult<Block>

Source

pub async fn async_get_ghostdag_data( &self, hash: Hash, ) -> ConsensusResult<ExternalGhostdagData>

Source

pub async fn async_get_block_children(&self, hash: Hash) -> Option<Vec<Hash>>

Source

pub async fn async_get_block_parents( &self, hash: Hash, ) -> Option<Arc<Vec<Hash>>>

Source

pub async fn async_get_block_status(&self, hash: Hash) -> Option<BlockStatus>

Source

pub async fn async_get_block_acceptance_data( &self, hash: Hash, ) -> ConsensusResult<Arc<AcceptanceData>>

Source

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

Source

pub async fn async_is_chain_block(&self, hash: Hash) -> ConsensusResult<bool>

Source

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

Source

pub async fn async_get_missing_block_body_hashes( &self, high: Hash, ) -> ConsensusResult<Vec<Hash>>

Source

pub async fn async_pruning_point(&self) -> Hash

Source

pub async fn async_get_daa_window( &self, hash: Hash, ) -> ConsensusResult<Vec<Hash>>

Source

pub async fn async_get_trusted_block_associated_ghostdag_data_block_hashes( &self, hash: Hash, ) -> ConsensusResult<Vec<Hash>>

Source

pub async fn async_estimate_network_hashes_per_second( &self, start_hash: Option<Hash>, window_size: usize, ) -> ConsensusResult<u64>

Source

pub async fn async_validate_pruning_points(&self) -> ConsensusResult<()>

Source

pub async fn async_are_pruning_points_violating_finality( &self, pp_list: PruningPointsList, ) -> bool

Source

pub async fn async_creation_timestamp(&self) -> u64

Source

pub async fn async_finality_point(&self) -> Hash

Trait Implementations§

Source§

impl Clone for ConsensusSessionOwned

Source§

fn clone(&self) -> ConsensusSessionOwned

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S> CastArc for S
where S: CastFromSync + ?Sized,

Source§

fn cast<T>(self: Arc<S>) -> Result<Arc<T>, Arc<S>>
where T: 'static + ?Sized,

Casts an Arc for this trait into that for type T.
Source§

impl<S> CastBox for S
where S: CastFrom + ?Sized,

Source§

fn cast<T>(self: Box<S>) -> Result<Box<T>, Box<S>>
where T: 'static + ?Sized,

Casts a box to this trait into that of type T. If fails, returns the receiver.
Source§

impl<T> CastFrom for T
where T: Any + 'static,

Source§

fn ref_any(&self) -> &(dyn Any + 'static)

Returns a immutable reference to Any, which is backed by the type implementing this trait.
Source§

fn mut_any(&mut self) -> &mut (dyn Any + 'static)

Returns a mutable reference to Any, which is backed by the type implementing this trait.
Source§

fn box_any(self: Box<T>) -> Box<dyn Any>

Returns a Box of Any, which is backed by the type implementing this trait.
Source§

fn rc_any(self: Rc<T>) -> Rc<dyn Any>

Returns an Rc of Any, which is backed by the type implementing this trait.
Source§

impl<T> CastFromSync for T
where T: Sync + Send + 'static,

Source§

fn arc_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

impl<S> CastMut for S
where S: CastFrom + ?Sized,

Source§

fn cast<T>(&mut self) -> Option<&mut T>
where T: 'static + ?Sized,

Casts a mutable reference to this trait into that of type T.
Source§

impl<S> CastRc for S
where S: CastFrom + ?Sized,

Source§

fn cast<T>(self: Rc<S>) -> Result<Rc<T>, Rc<S>>
where T: 'static + ?Sized,

Casts an Rc for this trait into that for type T.
Source§

impl<S> CastRef for S
where S: CastFrom + ?Sized,

Source§

fn cast<T>(&self) -> Option<&T>
where T: 'static + ?Sized,

Casts a reference to this trait into that of type T.
Source§

fn impls<T>(&self) -> bool
where T: 'static + ?Sized,

Tests if this trait object can be cast into T.
Source§

impl<T> CloneAny for T
where T: Any + Clone + Send + Sync,

§

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

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

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, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

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, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U

Source§

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