Tangle

Struct Tangle 

Source
pub struct Tangle<B> { /* private fields */ }
Expand description

A Tangle wrapper designed to encapsulate milestone state.

Implementations§

Source§

impl<B: StorageBackend> Tangle<B>

Source

pub fn new(config: TangleConfig, storage: ResourceHandle<B>) -> Self

Create a new Tangle instance with the given configuration and storage handle.

Source

pub async fn shutdown(self)

Shut down the tangle, terminating any and all worker tasks.

Source

pub fn config(&self) -> &TangleConfig

Get the configuration of this tangle.

Source

pub async fn insert( &self, message: Message, message_id: MessageId, metadata: MessageMetadata, ) -> Option<MessageRef>

Insert a message into the tangle.

Source

pub async fn add_milestone(&self, idx: MilestoneIndex, milestone: Milestone)

Add a milestone to the tangle.

Source

pub async fn remove_milestone(&self, index: MilestoneIndex)

Remove a milestone from the tangle.

Source

pub async fn get_milestone(&self, index: MilestoneIndex) -> Option<Milestone>

Get the milestone from the tangle that corresponds to the given milestone index.

Source

pub async fn get_milestone_message( &self, index: MilestoneIndex, ) -> Option<MessageRef>

Get the message associated with the given milestone index from the tangle.

Source

pub async fn get_milestone_message_id( &self, index: MilestoneIndex, ) -> Option<MessageId>

Get the message ID associated with the given milestone index from the tangle.

Source

pub async fn contains_milestone(&self, idx: MilestoneIndex) -> bool

Return whether the tangle contains the given milestone index.

Source

pub fn get_latest_milestone_index(&self) -> MilestoneIndex

Get the index of the latest milestone.

Source

pub fn update_latest_milestone_index(&self, new_index: MilestoneIndex)

Update the index of the lastest milestone.

Source

pub fn get_solid_milestone_index(&self) -> MilestoneIndex

Get the latest solid milestone index.

Source

pub fn update_solid_milestone_index(&self, new_index: MilestoneIndex)

Update the latest solid milestone index.

Source

pub fn get_confirmed_milestone_index(&self) -> MilestoneIndex

Get the latest confirmed milestone index.

Source

pub fn update_confirmed_milestone_index(&self, new_index: MilestoneIndex)

Update the latest confirmed milestone index.

Source

pub fn get_snapshot_index(&self) -> MilestoneIndex

Get the snapshot index.

Source

pub fn update_snapshot_index(&self, new_index: MilestoneIndex)

Update the snapshot index.

Source

pub fn get_pruning_index(&self) -> MilestoneIndex

Get the pruning index.

Source

pub fn update_pruning_index(&self, new_index: MilestoneIndex)

Update the pruning index.

Source

pub fn get_entry_point_index(&self) -> MilestoneIndex

Get the entry point index.

Source

pub fn update_entry_point_index(&self, new_index: MilestoneIndex)

Update the entry point index.

Source

pub fn is_synced(&self) -> bool

Return whether the tangle is within the default sync threshold.

Source

pub fn get_sync_threshold(&self) -> u32

Get the number of milestones until the tangle is synced.

Source

pub fn is_synced_threshold(&self, threshold: u32) -> bool

Return whether the tangle is within the given sync threshold.

Source

pub fn is_confirmed(&self) -> bool

Return whether the tangle is fully confirmed.

Source

pub fn is_confirmed_threshold(&self, threshold: u32) -> bool

Return whether the tangle is within the given confirmation threshold.

Source

pub async fn get_solid_entry_point_index( &self, sep: &SolidEntryPoint, ) -> Option<MilestoneIndex>

Get the milestone index associated with the given solid entry point.

Source

pub async fn add_solid_entry_point( &self, sep: SolidEntryPoint, index: MilestoneIndex, )

Add the given solid entry point to the given milestone index.

Source

pub async fn get_solid_entry_points( &self, ) -> HashMap<SolidEntryPoint, MilestoneIndex>

Returns a copy of all solid entry points.

Source

pub async fn remove_solid_entry_point(&self, sep: &SolidEntryPoint)

Removes the given solid entry point from the set of solid entry points.

Source

pub async fn clear_solid_entry_points(&self)

Clear all solid entry points.

Source

pub async fn replace_solid_entry_points( &self, new_seps: impl IntoIterator<Item = (SolidEntryPoint, MilestoneIndex)>, )

Replaces all solid entry points.

Source

pub async fn is_solid_entry_point(&self, id: &MessageId) -> bool

Returns whether the message associated with given solid entry point is a solid entry point.

Source

pub async fn is_solid_message(&self, id: &MessageId) -> bool

Returns whether the message associated with the given message ID is solid.

Source

pub async fn omrsi(&self, id: &MessageId) -> Option<IndexId>

Get the oldest milestone root snapshot index.

Source

pub async fn ymrsi(&self, id: &MessageId) -> Option<IndexId>

Get the youngest milestone root snapshot index.

Source

pub async fn insert_tip(&self, message_id: MessageId, parents: Vec<MessageId>)

Insert the given message ID and parents as a tip.

Source

pub async fn update_tip_scores(&self)

Update tip scores.

Source

pub async fn get_messages_to_approve(&self) -> Option<Vec<MessageId>>

Return messages that require approving.

Source

pub async fn reduce_tips(&self)

Reduce tips.

Source

pub async fn non_lazy_tips_num(&self) -> usize

Return the number of non-lazy tips.

Source

pub async fn get(&self, message_id: &MessageId) -> Option<MessageRef>

Get the data of a vertex associated with the given message_id.

Source

pub async fn contains(&self, message_id: &MessageId) -> bool

Returns whether the message is stored in the Tangle.

Source

pub async fn get_metadata( &self, message_id: &MessageId, ) -> Option<MessageMetadata>

Get the metadata of a vertex associated with the given message_id.

Source

pub async fn get_vertex( &self, message_id: &MessageId, ) -> Option<impl Deref<Target = Vertex> + '_>

Get the metadata of a vertex associated with the given message_id.

Source

pub async fn update_metadata<R, Update>( &self, message_id: &MessageId, update: Update, ) -> Option<R>
where Update: FnOnce(&mut MessageMetadata) -> R,

Updates the metadata of a vertex.

Source

pub async fn get_children( &self, message_id: &MessageId, ) -> Option<Vec<MessageId>>

Returns the children of a vertex, if we know about them.

Auto Trait Implementations§

§

impl<B> !Freeze for Tangle<B>

§

impl<B> !RefUnwindSafe for Tangle<B>

§

impl<B> Send for Tangle<B>
where B: Sync + Send,

§

impl<B> Sync for Tangle<B>
where B: Sync + Send,

§

impl<B> Unpin for Tangle<B>

§

impl<B> UnwindSafe for Tangle<B>
where B: RefUnwindSafe,

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

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

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

Source§

fn vzip(self) -> V