Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: farming policies ordering and assignment #704

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

DylanVerstraete
Copy link
Contributor

@DylanVerstraete DylanVerstraete commented May 24, 2023

We didn't order farming policies on creation date / id, causing miss assignment of policies on testnet. #664

@@ -176,7 +176,10 @@ impl<B: Ord> PartialOrd for FarmingPolicy<B> {
impl<B: Ord> Ord for FarmingPolicy<B> {
fn cmp(&self, other: &Self) -> Ordering {
match self.farm_certification.cmp(&other.farm_certification) {
Ordering::Equal => self.node_certification.cmp(&other.node_certification),
Ordering::Equal => match self.node_certification.cmp(&other.node_certification) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cmp() is set for being able to use sort() on FarmingPolicy, correct?
For our usage we only care about the creation time so why id ordering is not enough?

Copy link
Contributor Author

@DylanVerstraete DylanVerstraete May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting by ID will always make sure policies are sorted by creation time since ID is incremental. I also implemented like this so the tests would be work.

@DylanVerstraete DylanVerstraete marked this pull request as ready for review May 31, 2023 14:03
@DylanVerstraete
Copy link
Contributor Author

@renauter thanks for reviewing and fixing the test. I think we are good now :-)

@DylanVerstraete DylanVerstraete merged commit b9a9cca into development Jun 6, 2023
@DylanVerstraete DylanVerstraete deleted the fix_farming_policies branch June 6, 2023 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants