fn cmp(&self, other: &Self) -> Ordering {
        if self.partial_cumulative_work != other.partial_cumulative_work {
            self.partial_cumulative_work
                .cmp(&other.partial_cumulative_work)
        } else {
            let self_hash = self
                .blocks
                .values()
                .last()
                .expect("always at least 1 element")
                .hash;

            let other_hash = other
                .blocks
                .values()
                .last()
                .expect("always at least 1 element")
                .hash;

            // This comparison is a tie-breaker within the local node, so it does not need to
            // be consistent with the ordering on `ExpandedDifficulty` and `block::Hash`.
            match self_hash.0.cmp(&other_hash.0) {
                Ordering::Equal => unreachable!("Chain tip block hashes are always unique"),
                ordering => ordering,
            }
        }
    }
/// Chain order for the [`NonFinalizedState`]'s `chain_set`.
/// Chains with higher cumulative Proof of Work are [`Ordering::Greater`],
/// breaking ties using the tip block hash.
///
/// Despite the consensus rules, Zebra uses the tip block hash as a tie-breaker.
/// Zebra blocks are downloaded in parallel, so download timestamps may not be unique.
/// (And Zebra currently doesn't track download times, because [`Block`]s are immutable.)
///
/// This departure from the consensus rules may delay network convergence,
/// for as long as the greater hash belongs to the later mined block.
/// But Zebra nodes should converge as soon as the tied work is broken.
///
/// "At a given point in time, each full validator is aware of a set of candidate blocks.
/// These form a tree rooted at the genesis block, where each node in the tree
/// refers to its parent via the hashPrevBlock block header field.
///
/// A path from the root toward the leaves of the tree consisting of a sequence
/// of one or more valid blocks consistent with consensus rules,
/// is called a valid block chain.
///
/// In order to choose the best valid block chain in its view of the overall block tree,
/// a node sums the work ... of all blocks in each valid block chain,
/// and considers the valid block chain with greatest total work to be best.
///
/// To break ties between leaf blocks, a node will prefer the block that it received first.
///
/// The consensus protocol is designed to ensure that for any given block height,
/// the vast majority of nodes should eventually agree on their best valid block chain
/// up to that height."
///
/// https://zips.z.cash/protocol/protocol.pdf#blockchain
///
/// # Correctness
///
/// `Chain::cmp` is used in a `BTreeSet`, so the fields accessed by `cmp` must not have
/// interior mutability.
///
/// # Panics
///
/// If two chains compare equal.
///
/// This panic enforces the `NonFinalizedState.chain_set` unique chain invariant.
///
/// If the chain set contains duplicate chains, the non-finalized state might
/// handle new blocks or block finalization incorrectly.


Despite the consensus rules, Zebra uses the tip block hash as a tie-breaker.
Zebra blocks are downloaded in parallel, so download timestamps may not be unique.
(And Zebra currently doesn't track download times, because [`Block`]s are immutable.)

This departure from the consensus rules may delay network convergence,
for as long as the greater hash belongs to the later mined block.
But Zebra nodes should converge as soon as the tied work is broken.

"At a given point in time, each full validator is aware of a set of candidate blocks.
These form a tree rooted at the genesis block, where each node in the tree
refers to its parent via the hashPrevBlock block header field.

A path from the root toward the leaves of the tree consisting of a sequence
of one or more valid blocks consistent with consensus rules,
is called a valid block chain.

In order to choose the best valid block chain in its view of the overall block tree,
a node sums the work ... of all blocks in each valid block chain,
and considers the valid block chain with greatest total work to be best.

To break ties between leaf blocks, a node will prefer the block that it received first.

The consensus protocol is designed to ensure that for any given block height,
the vast majority of nodes should eventually agree on their best valid block chain
up to that height."


Despite the consensus rules Zebra uses the tip block hash as a tie - breaker . Zebra blocks are downloaded in parallel so download timestamps may not be unique . ( And Zebra currently doesn ' t track download times because [ ` Block ` ] s are immutable . ) This departure from the consensus rules may delay network convergence for as long as the greater hash belongs to the later mined block . But Zebra nodes should converge as soon as the tied work is broken . " At a given point in time each full validator is aware of a set of candidate blocks . These form a tree rooted at the genesis block where each node in the tree refers to its parent via the hashPrevBlock block header field . A path from the root toward the leaves of the tree consisting of a sequence of one or more valid blocks consistent with consensus rules is called a valid block chain . In order to choose the best valid block chain in its view of the overall block tree a node sums the work ... of all blocks in each valid block chain and considers the valid block chain with greatest total work to be best . To break ties between leaf blocks a node will prefer the block that it received first . The consensus protocol is designed to ensure that for any given block height the vast majority of nodes should eventually agree on their best valid block chain up to that height . "
fn cmp(&self, other: &Self) -> Ordering {
        if self.partial_cumulative_work != other.partial_cumulative_work {
            self.partial_cumulative_work
                .cmp(&other.partial_cumulative_work)
        } else {
            let self_hash = self
                .blocks
                .values()
                .last()
                .expect("always at least 1 element")
                .hash;
            let other_hash = other
                .blocks
                .values()
                .last()
                .expect("always at least 1 element")
                .hash;
            // This comparison is a tie-breaker within the local node, so it does not need to
            // be consistent with the ordering on `ExpandedDifficulty` and `block::Hash`.
            match self_hash.0.cmp(&other_hash.0) {
                Ordering::Equal => unreachable!("Chain tip block hashes are always unique"),
                ordering => ordering,
            }
        }
    }
fn cmp ( & self , other : & Self ) -> Ordering { if self . partial_cumulative_work != other . partial_cumulative_work { self . partial_cumulative_work . cmp ( & other . partial_cumulative_work ) } else { let self_hash = self . blocks . values ( ) . last ( ) . expect ( " " ) . hash ; let other_hash = other . blocks . values ( ) . last ( ) . expect ( " " ) . hash ; // This comparison is a tie-breaker within the local node, so it does not need to // be consistent with the ordering on `ExpandedDifficulty` and `block::Hash`. match self_hash . 0 . cmp ( & other_hash . 0 ) { Ordering :: Equal => unreachable ! ( " " ) , ordering => ordering , } } }
Chain order for the [`NonFinalizedState`]'s `chain_set`.
Chain order for the [ ` NonFinalizedState ` ] ' s ` chain_set ` .
&self
other
&Self
correctness
`Chain::cmp` is used in a `BTreeSet`, so the fields accessed by `cmp` must not have
interior mutability.
` Chain :: cmp ` is used in a ` BTreeSet ` so the fields accessed by ` cmp ` must not have interior mutability .
panics
If two chains compare equal.

This panic enforces the `NonFinalizedState.chain_set` unique chain invariant.

If the chain set contains duplicate chains, the non-finalized state might
handle new blocks or block finalization incorrectly.
If two chains compare equal . This panic enforces the ` NonFinalizedState . chain_set ` unique chain invariant . If the chain set contains duplicate chains the non - finalized state might handle new blocks or block finalization incorrectly .