mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 12:48:00 +00:00
Saner weights + lease calcuation fix. (#2778)
And have proper benchmarks. --------- Co-authored-by: eskimor <eskimor@no-such-url.com> Co-authored-by: command-bot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
@@ -326,18 +326,6 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
tracker.into_iter().collect()
|
||||
}
|
||||
|
||||
/// Current lease index and how many blocks we are already in.
|
||||
pub fn lease_period_index_plus_progress(
|
||||
b: BlockNumberFor<T>,
|
||||
) -> Option<(<Self as Leaser<BlockNumberFor<T>>>::LeasePeriod, BlockNumberFor<T>)> {
|
||||
// Note that blocks before `LeaseOffset` do not count as any lease period.
|
||||
let offset_block_now = b.checked_sub(&T::LeaseOffset::get())?;
|
||||
let lease_period = offset_block_now / T::LeasePeriod::get();
|
||||
let in_lease = offset_block_now % T::LeasePeriod::get();
|
||||
|
||||
Some((lease_period, in_lease))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> crate::traits::OnSwap for Pallet<T> {
|
||||
@@ -461,8 +449,12 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
|
||||
}
|
||||
|
||||
fn lease_period_index(b: BlockNumberFor<T>) -> Option<(Self::LeasePeriod, bool)> {
|
||||
Self::lease_period_index_plus_progress(b)
|
||||
.map(|(period, progress)| (period, progress.is_zero()))
|
||||
// Note that blocks before `LeaseOffset` do not count as any lease period.
|
||||
let offset_block_now = b.checked_sub(&T::LeaseOffset::get())?;
|
||||
let lease_period = offset_block_now / T::LeasePeriod::get();
|
||||
let at_begin = (offset_block_now % T::LeasePeriod::get()).is_zero();
|
||||
|
||||
Some((lease_period, at_begin))
|
||||
}
|
||||
|
||||
fn already_leased(
|
||||
|
||||
Reference in New Issue
Block a user