pub struct DAG<N: Network> { /* private fields */ }Expand description
Maintains a directed acyclic graph (DAG) of certificates, from which we build a totally-ordered blockchain.
The DAG is updated in rounds, where each validator adds at most one new batch. Certificates older than GC are removed, as they are not longer needed.
Invariants:
- For each entry in
graphthere is a corresponding certificate ID inrecent_committed_ids. last_committed_round, if >0, is equal to the largest key inrecent_commit_ids.
Implementations§
Source§impl<N: Network> DAG<N>
impl<N: Network> DAG<N>
Sourcepub const fn graph(
&self,
) -> &BTreeMap<u64, HashMap<Address<N>, BatchCertificate<N>>>
pub const fn graph( &self, ) -> &BTreeMap<u64, HashMap<Address<N>, BatchCertificate<N>>>
Returns the DAG.
Sourcepub const fn last_committed_round(&self) -> u64
pub const fn last_committed_round(&self) -> u64
Returns the latest round a certificate was committed to.
Sourcepub fn is_recently_committed(
&self,
round: u64,
certificate_id: Field<N>,
) -> bool
pub fn is_recently_committed( &self, round: u64, certificate_id: Field<N>, ) -> bool
Returns true if the given certificate ID was recently committed.
Sourcepub fn contains_certificate_in_round(
&self,
round: u64,
certificate_id: Field<N>,
) -> bool
pub fn contains_certificate_in_round( &self, round: u64, certificate_id: Field<N>, ) -> bool
Returns true if the given certificate ID exists in the given round.
Returns the batch certificate for the given round and author.
Sourcepub fn get_certificate_for_round_with_id(
&self,
round: u64,
certificate_id: Field<N>,
) -> Option<BatchCertificate<N>>
pub fn get_certificate_for_round_with_id( &self, round: u64, certificate_id: Field<N>, ) -> Option<BatchCertificate<N>>
Returns the batch certificate for the given round and certificate ID.
Sourcepub fn get_certificates_for_round(
&self,
round: u64,
) -> Option<HashMap<Address<N>, BatchCertificate<N>>>
pub fn get_certificates_for_round( &self, round: u64, ) -> Option<HashMap<Address<N>, BatchCertificate<N>>>
Returns the batch certificates for the given round.
Sourcepub fn insert(&mut self, certificate: BatchCertificate<N>)
pub fn insert(&mut self, certificate: BatchCertificate<N>)
Inserts a certificate into the DAG.
Sourcepub fn commit(&mut self, certificate: &BatchCertificate<N>, max_gc_rounds: u64)
pub fn commit(&mut self, certificate: &BatchCertificate<N>, max_gc_rounds: u64)
Commits a certificate, removing all certificates for this author at or before this round from the DAG.
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for DAG<N>
impl<N> RefUnwindSafe for DAG<N>where
<N as Environment>::Projective: RefUnwindSafe,
<N as Environment>::Field: RefUnwindSafe,
<N as Environment>::Scalar: RefUnwindSafe,
<N as Network>::TransmissionChecksum: RefUnwindSafe,
<N as Network>::TransactionID: RefUnwindSafe,
N: RefUnwindSafe,
impl<N> Send for DAG<N>
impl<N> Sync for DAG<N>
impl<N> Unpin for DAG<N>
impl<N> UnsafeUnpin for DAG<N>
impl<N> UnwindSafe for DAG<N>where
<N as Environment>::Projective: RefUnwindSafe,
<N as Environment>::Field: RefUnwindSafe,
<N as Environment>::Scalar: RefUnwindSafe,
<N as Network>::TransmissionChecksum: RefUnwindSafe,
<N as Network>::TransactionID: RefUnwindSafe,
N: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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