mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-15 10:15:42 +00:00
[pallet-broker] Use saturating math in input validation (#4151)
Changes: - Saturate in the input validation of he drop history function or pallet-broker. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
committed by
GitHub
parent
4b5c3fd0cb
commit
8891b70fe2
@@ -419,7 +419,10 @@ impl<T: Config> Pallet<T> {
|
||||
pub(crate) fn do_drop_history(when: Timeslice) -> DispatchResult {
|
||||
let config = Configuration::<T>::get().ok_or(Error::<T>::Uninitialized)?;
|
||||
let status = Status::<T>::get().ok_or(Error::<T>::Uninitialized)?;
|
||||
ensure!(status.last_timeslice > when + config.contribution_timeout, Error::<T>::StillValid);
|
||||
ensure!(
|
||||
status.last_timeslice > when.saturating_add(config.contribution_timeout),
|
||||
Error::<T>::StillValid
|
||||
);
|
||||
let record = InstaPoolHistory::<T>::take(when).ok_or(Error::<T>::NoHistory)?;
|
||||
if let Some(payout) = record.maybe_payout {
|
||||
let _ = Self::charge(&Self::account_id(), payout);
|
||||
|
||||
Reference in New Issue
Block a user