53 releases (35 major breaking)

37.0.0 Sep 26, 2024
36.0.0 Jul 18, 2024
35.0.0 Jul 12, 2024
34.0.0 Jun 24, 2024
2.0.0-alpha.5 Mar 24, 2020

#3 in #heartbeat

Download history 1124/week @ 2024-08-26 579/week @ 2024-09-02 1093/week @ 2024-09-09 933/week @ 2024-09-16 1445/week @ 2024-09-23 1297/week @ 2024-09-30 878/week @ 2024-10-07 1202/week @ 2024-10-14 1762/week @ 2024-10-21 1244/week @ 2024-10-28 1232/week @ 2024-11-04 20856/week @ 2024-11-11 25390/week @ 2024-11-18 28318/week @ 2024-11-25 23113/week @ 2024-12-02 28345/week @ 2024-12-09

106,401 downloads per month
Used in 24 crates (5 directly)

Apache-2.0

2.5MB
46K SLoC

I'm online Module

If the local node is a validator (i.e. contains an authority key), this module gossips a heartbeat transaction with each new session. The heartbeat functions as a simple mechanism to signal that the node is online in the current era.

Received heartbeats are tracked for one era and reset with each new era. The module exposes two public functions to query if a heartbeat has been received in the current era or session.

The heartbeat is a signed transaction, which was signed using the session key and includes the recent best block number of the local validators chain as well as the NetworkState. It is submitted as an Unsigned Transaction via off-chain workers.

Interface

Public Functions

  • is_online - True if the validator sent a heartbeat in the current session.

Usage

use pallet_im_online::{self as im_online};

#[frame_support::pallet]
pub mod pallet {
    use super::*;
    use frame_support::pallet_prelude::*;
    use frame_system::pallet_prelude::*;

    #[pallet::pallet]
    pub struct Pallet<T>(_);

    #[pallet::config]
    pub trait Config: frame_system::Config + im_online::Config {}

    #[pallet::call]
    impl<T: Config> Pallet<T> {
        #[pallet::weight(0)]
        pub fn is_online(origin: OriginFor<T>, authority_index: u32) -> DispatchResult {
            let _sender = ensure_signed(origin)?;
            let _is_online = <im_online::Pallet<T>>::is_online(authority_index);
            Ok(())
        }
    }
}

Dependencies

This module depends on the Session module.

License: Apache-2.0

Release

Polkadot SDK stable2409

Dependencies

~17–31MB
~523K SLoC