Skip to content

Commit

Permalink
feat: add blocksperround
Browse files Browse the repository at this point in the history
  • Loading branch information
Akagi201 committed Jun 24, 2022
1 parent 7abef10 commit ba96b8e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions pallets/system-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use sp_runtime::traits::{AccountIdConversion, Saturating, Zero};
pub use types::*;
pub use weights::WeightInfo;
pub use RoundIndex;
use frame_support::inherent::Vec;
#[cfg(test)]
mod mock;

Expand Down Expand Up @@ -89,6 +90,9 @@ pub mod pallet {
/// ModuleID for creating sub account
#[pallet::constant]
type PalletId: Get<PalletId>;

#[pallet::constant]
type BlocksPerRound: Get<u32>;
}

#[pallet::pallet]
Expand All @@ -98,7 +102,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn round)]
/// Currend Round Information
pub(crate) type Round<T: Config> = StorageValue<_, RoundInfo<T::BlockNumber>, ValueQuery>;
pub(crate) type Round<T: Config> = StorageValue<_, RoundInfo<T::BlockNumber>, OptionQuery>;

#[pallet::storage]
#[pallet::getter(fn token_status)]
Expand Down Expand Up @@ -161,7 +165,11 @@ pub mod pallet {
let mut x = 0u32;
let mut y = 0u32;

let mut round = <Round<T>>::get();
let mut round = if let Some(round) = <Round<T>>::get() {
round
} else {
RoundInfo::new(1u32, 0u32.into(), T::BlocksPerRound::get())
};
// new round start
if round.should_update(n) {
// mutate round
Expand Down
6 changes: 4 additions & 2 deletions pallets/system-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ impl bifrost_farming::Config for Runtime {

parameter_types! {
pub const TreasuryAccount: AccountId32 = TREASURY_ACCOUNT;
pub const ThePalletId: PalletId = PalletId(*b"bf/sysst");
pub const BlocksPerRound: u32 = 100;
pub const SystemStakingPalletId: PalletId = PalletId(*b"bf/sysst");
}

impl system_staking::Config for Runtime {
Expand All @@ -303,7 +304,8 @@ impl system_staking::Config for Runtime {
type FarmingInfo = Farming;
type VtokenMintingInterface = VtokenMinting;
type TreasuryAccount = TreasuryAccount;
type PalletId = ThePalletId;
type PalletId = SystemStakingPalletId;
type BlocksPerRound = BlocksPerRound;
}

pub struct ExtBuilder {
Expand Down
5 changes: 5 additions & 0 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,10 @@ impl bifrost_farming::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const BlocksPerRound: u32 = prod_or_test!(1500, 100);
}

impl bifrost_system_staking::Config for Runtime {
type Event = Event;
type MultiCurrency = Currencies;
Expand All @@ -1805,6 +1809,7 @@ impl bifrost_system_staking::Config for Runtime {
type VtokenMintingInterface = VtokenMinting;
type TreasuryAccount = BifrostTreasuryAccount;
type PalletId = SystemStakingPalletId;
type BlocksPerRound = BlocksPerRound;
}

// Bifrost modules end
Expand Down

0 comments on commit ba96b8e

Please sign in to comment.