Skip to content

Commit

Permalink
Merge pull request AleoNet#2254 from AleoHQ/feat/subdag-eq
Browse files Browse the repository at this point in the history
Update `Subdag` equality check
  • Loading branch information
howardwu authored Dec 18, 2023
2 parents c5f609e + ee53c2d commit 1938636
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ledger/narwhal/subdag/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,23 @@ fn sanity_check_subdag_with_dfs<N: Network>(subdag: &BTreeMap<u64, IndexSet<Batc
&commit == subdag
}

#[derive(Clone, PartialEq, Eq)]
#[derive(Clone)]
pub struct Subdag<N: Network> {
/// The subdag of round certificates.
subdag: BTreeMap<u64, IndexSet<BatchCertificate<N>>>,
/// The election certificate IDs.
election_certificate_ids: IndexSet<Field<N>>,
}

impl<N: Network> PartialEq for Subdag<N> {
fn eq(&self, other: &Self) -> bool {
// Note: We do not check equality on `election_certificate_ids` as it would cause `Block::eq` to trigger false-positives.
self.subdag == other.subdag
}
}

impl<N: Network> Eq for Subdag<N> {}

impl<N: Network> Subdag<N> {
/// Initializes a new subdag.
pub fn from(
Expand Down

0 comments on commit 1938636

Please sign in to comment.