lighter
.
The dispatch origin for this call must be Signed and can only be called by the Id of the account going in front of lighter
.
Only works if
origin
has a greater Score
than lighter
.
dislocated
account has, through rewards or penalties, sufficiently changed its score that it should properly fall into a different bag than its current one.
Anyone can call this function about any potentially dislocated account.
Will always update the stored score of dislocated
to the correct score, based on ScoreProvider
.
If dislocated
does not exists, it returns an error.
Namespace
Bag
struct, which stores head and tail pointers to itself.
Namespace
Score::MAX
; that value does not need to be specified within the bag. For any two threshold lists, if one ends with Score::MAX
, the other one does not, and they are otherwise equal, the two lists will behave identically.
Calculation
It is recommended to generate the set of thresholds in a geometric series, such that there exists some constant ratio such that threshold[k + 1] == (threshold[k] * constant_ratio).max(threshold[k] + 1)
for all k
.
The helpers in the /utils/frame/generate-bags
module can simplify this calculation.
Examples
BagThresholds::get().is_empty()
, then all ids are put into the same bag, and iteration is strictly in insertion order.
BagThresholds::get().len() == 64
, and the thresholds are determined according to the procedure given above, then the constant ratio is equal to 2.
BagThresholds::get().len() == 200
, and the thresholds are determined according to the procedure given above, then the constant ratio is approximately equal to 1.248.
[1, 2, 3, ...]
, then an id with score 0 or 1 will fall into bag 0, an id with score 2 will fall into bag 1, etc.
List::migrate
can be called, which will perform the appropriate migration.
Namespace