Skip to content

Commit 5cd8ab8

Browse files
committed
Remove Ord and PartialOrd from AbsLockTime and RelLockTime.
Drop the consensus-u32 ordering that incorrectly compared height-based and time-based locktimes against each other.
1 parent fc39f20 commit 5cd8ab8

2 files changed

Lines changed: 4 additions & 28 deletions

File tree

src/primitives/absolute_locktime.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! Absolute Locktimes
44
5-
use core::{cmp, fmt};
5+
use core::fmt;
66

77
use bitcoin::absolute;
88

@@ -42,7 +42,7 @@ impl std::error::Error for AbsLockTimeError {
4242
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
4343
}
4444

45-
/// An absolute locktime that implements `Ord`.
45+
/// An absolute locktime.
4646
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4747
pub struct AbsLockTime(absolute::LockTime);
4848

@@ -84,18 +84,6 @@ impl From<AbsLockTime> for absolute::LockTime {
8484
fn from(lock_time: AbsLockTime) -> Self { lock_time.0 }
8585
}
8686

87-
impl cmp::PartialOrd for AbsLockTime {
88-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { Some(self.cmp(other)) }
89-
}
90-
91-
impl cmp::Ord for AbsLockTime {
92-
fn cmp(&self, other: &Self) -> cmp::Ordering {
93-
let this = self.0.to_consensus_u32();
94-
let that = other.0.to_consensus_u32();
95-
this.cmp(&that)
96-
}
97-
}
98-
9987
impl fmt::Display for AbsLockTime {
10088
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
10189
}

src/primitives/relative_locktime.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! Relative Locktimes
44
5-
use core::{cmp, convert, fmt};
5+
use core::{convert, fmt};
66

77
use bitcoin::{relative, Sequence};
88

@@ -30,7 +30,7 @@ impl std::error::Error for RelLockTimeError {
3030
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
3131
}
3232

33-
/// A relative locktime which implements `Ord`.
33+
/// A relative locktime.
3434
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3535
pub struct RelLockTime(Sequence);
3636

@@ -96,18 +96,6 @@ impl From<RelLockTime> for relative::LockTime {
9696
fn from(lock_time: RelLockTime) -> Self { lock_time.0.to_relative_lock_time().unwrap() }
9797
}
9898

99-
impl cmp::PartialOrd for RelLockTime {
100-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { Some(self.cmp(other)) }
101-
}
102-
103-
impl cmp::Ord for RelLockTime {
104-
fn cmp(&self, other: &Self) -> cmp::Ordering {
105-
let this = self.0.to_consensus_u32();
106-
let that = other.0.to_consensus_u32();
107-
this.cmp(&that)
108-
}
109-
}
110-
11199
impl fmt::Display for RelLockTime {
112100
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
113101
}

0 commit comments

Comments
 (0)