Cleanup the ExpandedDifficulty PartialOrd impl (#1466)
This commit is contained in:
parent
394634c933
commit
66e300be0a
|
|
@ -451,28 +451,26 @@ impl PartialOrd<block::Hash> for ExpandedDifficulty {
|
||||||
impl PartialEq<ExpandedDifficulty> for block::Hash {
|
impl PartialEq<ExpandedDifficulty> for block::Hash {
|
||||||
/// Is `self` equal to `other`?
|
/// Is `self` equal to `other`?
|
||||||
///
|
///
|
||||||
/// See `partial_cmp` for details.
|
/// See `<ExpandedDifficulty as PartialOrd<block::Hash>::partial_cmp`
|
||||||
|
/// for details.
|
||||||
fn eq(&self, other: &ExpandedDifficulty) -> bool {
|
fn eq(&self, other: &ExpandedDifficulty) -> bool {
|
||||||
other.eq(self)
|
other.eq(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialOrd<ExpandedDifficulty> for block::Hash {
|
impl PartialOrd<ExpandedDifficulty> for block::Hash {
|
||||||
/// `block::Hash`es are compared with `ExpandedDifficulty` thresholds by
|
/// How does `self` compare to `other`?
|
||||||
/// converting the hash to a 256-bit integer in little-endian order.
|
///
|
||||||
|
/// See `<ExpandedDifficulty as PartialOrd<block::Hash>::partial_cmp`
|
||||||
|
/// for details.
|
||||||
fn partial_cmp(&self, other: &ExpandedDifficulty) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &ExpandedDifficulty) -> Option<Ordering> {
|
||||||
use Ordering::*;
|
Some(
|
||||||
|
// Use the canonical implementation, but reverse the order
|
||||||
// Use the base implementation, but reverse the order.
|
other
|
||||||
match other
|
.partial_cmp(self)
|
||||||
.partial_cmp(self)
|
.expect("difficulties and hashes have a total order")
|
||||||
.expect("difficulties and hashes have a total order")
|
.reverse(),
|
||||||
{
|
)
|
||||||
Less => Greater,
|
|
||||||
Greater => Less,
|
|
||||||
Equal => Equal,
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue