Skip to content

Commit 0d5cc26

Browse files
Fix TransactionContext impls (#168)
1 parent 1e3ba3a commit 0d5cc26

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

aptos-indexer-processors-sdk/sdk/src/types/transaction_context.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,36 @@ impl<T> TransactionContext<T> {
3333
}
3434
}
3535

36-
impl<T> Ord for TransactionContext<T> {
36+
impl<T: Eq> Ord for TransactionContext<T> {
3737
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
3838
self.metadata
3939
.start_version
4040
.cmp(&other.metadata.start_version)
41+
.then_with(|| self.metadata.end_version.cmp(&other.metadata.end_version))
4142
}
4243
}
4344

44-
impl<T> PartialOrd for TransactionContext<T> {
45+
impl<T: PartialEq> PartialOrd for TransactionContext<T> {
4546
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
46-
Some(self.cmp(other))
47+
Some(
48+
self.metadata
49+
.start_version
50+
.cmp(&other.metadata.start_version)
51+
.then_with(|| self.metadata.end_version.cmp(&other.metadata.end_version)),
52+
)
4753
}
4854
}
4955

50-
impl<T> Eq for TransactionContext<T> {}
56+
impl<T: Eq> Eq for TransactionContext<T> {}
5157

52-
impl<T> PartialEq for TransactionContext<T> {
58+
impl<T: PartialEq> PartialEq for TransactionContext<T> {
5359
fn eq(&self, other: &Self) -> bool {
54-
self.metadata.start_version == other.metadata.start_version
60+
self.data == other.data && self.metadata == other.metadata
5561
}
5662
}
5763

5864
// Metadata about a batch of transactions
59-
#[derive(Clone, Default)]
65+
#[derive(Clone, Default, PartialEq)]
6066
pub struct TransactionMetadata {
6167
pub start_version: u64,
6268
pub end_version: u64,

0 commit comments

Comments
 (0)