Skip to content

Commit c170d55

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 a2b88b2 commit c170d55

2 files changed

Lines changed: 2 additions & 26 deletions

File tree

src/primitives/absolute_locktime.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -89,18 +89,6 @@ impl From<AbsLockTime> for absolute::LockTime {
8989
fn from(lock_time: AbsLockTime) -> Self { lock_time.0 }
9090
}
9191

92-
impl cmp::PartialOrd for AbsLockTime {
93-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { Some(self.cmp(other)) }
94-
}
95-
96-
impl cmp::Ord for AbsLockTime {
97-
fn cmp(&self, other: &Self) -> cmp::Ordering {
98-
let this = self.0.to_consensus_u32();
99-
let that = other.0.to_consensus_u32();
100-
this.cmp(&that)
101-
}
102-
}
103-
10492
impl fmt::Display for AbsLockTime {
10593
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
10694
}

src/primitives/relative_locktime.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -101,18 +101,6 @@ impl From<RelLockTime> for relative::LockTime {
101101
fn from(lock_time: RelLockTime) -> Self { lock_time.0.to_relative_lock_time().unwrap() }
102102
}
103103

104-
impl cmp::PartialOrd for RelLockTime {
105-
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { Some(self.cmp(other)) }
106-
}
107-
108-
impl cmp::Ord for RelLockTime {
109-
fn cmp(&self, other: &Self) -> cmp::Ordering {
110-
let this = self.0.to_consensus_u32();
111-
let that = other.0.to_consensus_u32();
112-
this.cmp(&that)
113-
}
114-
}
115-
116104
impl fmt::Display for RelLockTime {
117105
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
118106
}

0 commit comments

Comments
 (0)