mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-09 17:37:26 +00:00
[pallet_broker] Remove leases that have already expired in rotate_sale (#3213)
Leases can be force set, but since `Leases` is a `StorageValue`, if a lease misses its sale rotation in which it should expire, it can never be cleared. This can happen if a lease is added with an `until` timeslice that lies in a region whose sale has already started or has passed, even if the timeslice itself hasn't passed. This solves that issue in a minimal way, with all expired leases being cleaned up in each sale rotation, not just the ones that are expiring in the coming region. TODO: - [x] Write test
This commit is contained in:
@@ -216,7 +216,9 @@ impl<T: Config> Pallet<T> {
|
||||
let assignment = CoreAssignment::Task(task);
|
||||
let schedule = BoundedVec::truncate_from(vec![ScheduleItem { mask, assignment }]);
|
||||
Workplan::<T>::insert((region_begin, first_core), &schedule);
|
||||
let expiring = until >= region_begin && until < region_end;
|
||||
// Separate these to avoid missed expired leases hanging around forever.
|
||||
let expired = until < region_end;
|
||||
let expiring = until >= region_begin && expired;
|
||||
if expiring {
|
||||
// last time for this one - make it renewable.
|
||||
let renewal_id = AllowedRenewalId { core: first_core, when: region_end };
|
||||
@@ -231,7 +233,7 @@ impl<T: Config> Pallet<T> {
|
||||
Self::deposit_event(Event::LeaseEnding { when: region_end, task });
|
||||
}
|
||||
first_core.saturating_inc();
|
||||
!expiring
|
||||
!expired
|
||||
});
|
||||
Leases::<T>::put(&leases);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user