Skip to content

Commit

Permalink
fix recursion loop
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Oct 1, 2024
1 parent f295fe5 commit b292d3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app-libs/sgx-runtime/pallets/guess-the-number/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub mod pallet {
}

#[pallet::call_index(1)]
#[pallet::weight((<T as Config>::WeightInfo::push_by_one_day(), DispatchClass::Normal, Pays::Yes)
#[pallet::weight((<T as Config>::WeightInfo::guess(), DispatchClass::Normal, Pays::Yes)
)]
pub fn guess(origin: OriginFor<T>, guess: GuessType) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
Expand Down Expand Up @@ -209,7 +209,7 @@ where
fn end_round() -> DispatchResult {
let current_round_index = <CurrentRoundIndex<T>>::get();
info!("ending round {}", current_round_index);

Self::payout_winners();
<LastWinners<T>>::put(Self::winners());
<Winners<T>>::kill();
<LastWinningDistance<T>>::put(Self::winning_distance().unwrap_or(GuessType::MAX));
Expand All @@ -228,7 +228,11 @@ where
<LuckyNumber<T>>::put(lucky_number);
Ok(())
}

}
impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T>
where
sp_core::H256: From<<T as frame_system::Config>::Hash>,
{
fn on_timestamp_set(now: T::Moment) {
if Self::next_round_timestamp() == T::Moment::zero() {
// only executed in first block after genesis.
Expand All @@ -250,11 +254,6 @@ where
};
}
}
impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
fn on_timestamp_set(moment: T::Moment) {
Self::on_timestamp_set(moment)
}
}
#[cfg(test)]
mod mock;
#[cfg(test)]
Expand Down
5 changes: 5 additions & 0 deletions app-libs/sgx-runtime/pallets/guess-the-number/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ pub use frame_support::weights::{constants::RocksDbWeight, Weight};
/// Weight functions needed for pallet_parentchain.
pub trait WeightInfo {
fn push_by_one_day() -> Weight;
fn guess() -> Weight;
}

/// Weights for pallet_parentchain using the Integritee parachain node and recommended hardware.
impl WeightInfo for () {
fn push_by_one_day() -> Weight {
Weight::from_parts(10_000, 0u64)
}

fn guess() -> Weight {
Weight::from_parts(10_000, 0u64)
}
}

0 comments on commit b292d3c

Please sign in to comment.