-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Additional zero bid logic for Society pallet #4604
Additional zero bid logic for Society pallet #4604
Conversation
// Find the user who falls on that point | ||
let primary = accepted.iter().find(|e| e.1 > primary_point) | ||
// Find the zero bid or the user who falls on that point | ||
let primary = accepted.iter().find(|e| e.2.is_zero() || e.1 > primary_point) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will the zero bid always be the first in the list? if not then the primary_point
bidder will be chosen if it comes before the zero bidder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We must assume bids
is sorted by value. If so, then candidates
will be sorted by value. If so, then accepted
will be sorted by value.
If you would like me to write this assumption down near this code I can do that.
…abrizi/substrate into shawntabrizi-bump-society
Note that this extra logic currently does not do anything per the implementation of `binary_search` in Rust.
I will work on another implementation of this logic introducing a new storage item |
i think it would still be worth cleaning it up if you've already started, but can merge this as is since it's strictly better. |
This introduces some additional logic around users trying to join society with zero value bids.
A new test verifies that these two points are handled, correctly, and all other existing tests/logic continue to work unaffected.