Skip to content

Commit 806c1af

Browse files
committed
use derived Ord
1 parent d7c6502 commit 806c1af

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

toolkit/primitives/authority-selection-inherents/src/filter_invalid_candidates.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct RegisterValidatorSignedMessage {
2222
pub registration_utxo: UtxoId,
2323
}
2424

25-
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
25+
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
2626
pub struct CandidateWithStake<TAccountId, TAccountKeys> {
2727
pub stake_pool_pub_key: StakePoolPublicKey,
2828
/// Amount of ADA staked/locked by the Authority Candidate
@@ -31,29 +31,18 @@ pub struct CandidateWithStake<TAccountId, TAccountKeys> {
3131
pub account_keys: TAccountKeys,
3232
}
3333

34-
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
34+
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
3535
pub struct PermissionedCandidate<TAccountId, TAccountKeys> {
3636
pub account_id: TAccountId,
3737
pub account_keys: TAccountKeys,
3838
}
3939

40-
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)]
40+
#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, PartialOrd, Ord)]
4141
pub enum Candidate<TAccountId, TAccountKeys> {
4242
Permissioned(PermissionedCandidate<TAccountId, TAccountKeys>),
4343
Registered(CandidateWithStake<TAccountId, TAccountKeys>),
4444
}
4545

46-
impl<TAccountId: Ord, TAccountKeys: Eq> PartialOrd for Candidate<TAccountId, TAccountKeys> {
47-
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
48-
Some(self.cmp(other))
49-
}
50-
}
51-
impl<TAccountId: Ord, TAccountKeys: Eq> Ord for Candidate<TAccountId, TAccountKeys> {
52-
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
53-
self.account_id().cmp(other.account_id())
54-
}
55-
}
56-
5746
impl<AuthorityId, AuthorityKeys> From<Candidate<AuthorityId, AuthorityKeys>>
5847
for CommitteeMember<AuthorityId, AuthorityKeys>
5948
{

toolkit/primitives/domain/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ impl Display for McEpochNumber {
6060
}
6161
}
6262
/// Amount of Lovelace (which is a fraction of 1 ADA) staked/locked on Cardano
63-
#[derive(Default, Clone, Copy, Debug, Encode, Decode, TypeInfo, ToDatum, PartialEq, Eq)]
63+
#[derive(
64+
Default, Clone, Copy, Debug, Encode, Decode, TypeInfo, ToDatum, PartialEq, Eq, PartialOrd, Ord,
65+
)]
6466
#[cfg_attr(feature = "serde", derive(Serialize))]
6567
pub struct StakeDelegation(pub u64);
6668

0 commit comments

Comments
 (0)