3139ffa25e
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
60 lines
1.9 KiB
Markdown
60 lines
1.9 KiB
Markdown
# 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.
|
|
|
|
- [`im_online::Config`](https://docs.rs/pezpallet-im-online/latest/pallet_im_online/trait.Config.html)
|
|
- [`Call`](https://docs.rs/pezpallet-im-online/latest/pallet_im_online/enum.Call.html)
|
|
- [`Module`](https://docs.rs/pezpallet-im-online/latest/pallet_im_online/struct.Module.html)
|
|
|
|
## Interface
|
|
|
|
### Public Functions
|
|
|
|
- `is_online` - True if the validator sent a heartbeat in the current session.
|
|
|
|
## Usage
|
|
|
|
```rust
|
|
use pallet_im_online::{self as im_online};
|
|
|
|
#[frame_support::pezpallet]
|
|
pub mod pezpallet {
|
|
use super::*;
|
|
use frame_support::pallet_prelude::*;
|
|
use frame_system::pallet_prelude::*;
|
|
|
|
#[pezpallet::pezpallet]
|
|
pub struct Pezpallet<T>(_);
|
|
|
|
#[pezpallet::config]
|
|
pub trait Config: frame_system::Config + im_online::Config {}
|
|
|
|
#[pezpallet::call]
|
|
impl<T: Config> Pezpallet<T> {
|
|
#[pezpallet::weight(0)]
|
|
pub fn is_online(origin: OriginFor<T>, authority_index: u32) -> DispatchResult {
|
|
let _sender = ensure_signed(origin)?;
|
|
let _is_online = <im_online::Pezpallet<T>>::is_online(authority_index);
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
This module depends on the [Session module](https://docs.rs/pezpallet-session/latest/pallet_session/).
|
|
|
|
License: Apache-2.0
|