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

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


1 Answer 1


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

impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
    /// Initialization
    fn on_initialize(now: BlockNumberFor<T>) -> Weight {

    /// 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() {

        // remove temporary "environment" entry from storage

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.