2

Where can I find Tomasz Drwięga Off-chain DB indexing example, implementing the following runtime function?

fn on_finalize(_n: BlockNumberFor<T>){}

TIA

1 Answer 1

1

I found out it's just a hook, so no worries, all good.

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
    /// Initialization
    fn on_initialize(now: BlockNumberFor<T>) -> Weight {
        Self::do_initialize(now);
        0
    }

    /// Block finalization
    fn on_finalize(_n: BlockNumberFor<T>) {
        // at the end of the block, we can safely include the new VRF output
        // from this block into the under-construction randomness. If we've determined
        // that this block was the first in a new epoch, the changeover logic has
        // already occurred at this point, so the under-construction randomness
        // will only contain outputs from the right epoch.
        if let Some(Some(randomness)) = Initialized::<T>::take() {
            Self::deposit_randomness(&randomness);
        }

        // remove temporary "environment" entry from storage
        Lateness::<T>::kill();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.