mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
API for registering inactive funds (#12813)
* API for registering inactive funds * Build fixes. * Update frame/treasury/src/lib.rs * Fix * Fixes * Fixes
This commit is contained in:
@@ -223,6 +223,10 @@ pub mod pallet {
|
||||
OptionQuery,
|
||||
>;
|
||||
|
||||
/// The amount which has been reported as inactive to Currency.
|
||||
#[pallet::storage]
|
||||
pub type Inactive<T: Config<I>, I: 'static = ()> = StorageValue<_, BalanceOf<T, I>, ValueQuery>;
|
||||
|
||||
/// Proposal indices that have been approved but not yet awarded.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn approvals)]
|
||||
@@ -316,6 +320,16 @@ pub mod pallet {
|
||||
/// - The weight is overestimated if some approvals got missed.
|
||||
/// # </weight>
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
let pot = Self::pot();
|
||||
let deactivated = Inactive::<T, I>::get();
|
||||
if pot != deactivated {
|
||||
match (pot > deactivated, pot.max(deactivated) - pot.min(deactivated)) {
|
||||
(true, delta) => T::Currency::deactivate(delta),
|
||||
(false, delta) => T::Currency::reactivate(delta),
|
||||
}
|
||||
Inactive::<T, I>::put(&pot);
|
||||
}
|
||||
|
||||
// Check to see if we should spend some funds!
|
||||
if (n % T::SpendPeriod::get()).is_zero() {
|
||||
Self::spend_funds()
|
||||
|
||||
Reference in New Issue
Block a user