Crate pallet_gear_messenger
source ·Expand description
§Gear Messenger Pallet
The Gear Messenger Pallet provides functionality for handling messages.
§Overview
The Gear Messenger Pallet’s main aim is to separate message storages out of Gear’s execution logic and provide soft functionality to manage them.
The Gear Messenger Pallet provides functions for:
- Counting amount of messages sent from outside (from extrinsics) within the current block.
- Counting amount of messages removed from queue to be processed or skipped within the current block.
- Managing continuation of queue processing within the current block.
- Storing and managing message queue, it’s pushing and popping algorithms.
- Storing and managing mailbox, it’s insertion and removal algorithms,
including the value claiming with Balances Pallet as
Currency
Config
’s associated type.
§Interface
The Gear Messenger Pallet implements gear_common::storage::Messenger
trait
and shouldn’t contain any other functionality, except this trait declares.
§Usage
How to use the messaging functionality from the Gear Messenger Pallet:
- Implement it’s
Config
for your runtime with specifiedCurrency
type.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl pallet_gear_messenger::Config for Runtime {
type Currency = .. ;
}
// ... //
- Provide associated type for your pallet’s
Config
, which implementsgear_common::storage::Messenger
trait, specifying associated types if needed.
ⓘ
// `some_pallet/src/lib.rs`
// ... //
use gear_common::storage::Messenger;
#[pallet::config]
pub trait Config: frame_system::Config {
// .. //
type Messenger: Messenger<Capacity = u32>;
// .. //
}
- Declare Gear Messenger Pallet in your
construct_runtime!
macro.
ⓘ
// `runtime/src/lib.rs`
// ... //
construct_runtime!(
pub enum Runtime
where // ... //
{
// ... //
GearMessenger: pallet_gear_messenger,
// ... //
}
);
// ... //
GearMessenger: pallet_gear_messenger
- Set
GearMessenger
as your palletConfig
’s `Messenger type.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl some_pallet::Config for Runtime {
// ... //
type Messenger = GearMessenger;
// ... //
}
// ... //
- Work with Gear Messenger Pallet in your pallet with provided associated type interface.
§Genesis config
The Gear Messenger Pallet doesn’t depend on the GenesisConfig
.
§Assumptions
- You should manually control storage load from queue and mailbox length overflow (see Gear Payment Pallet).
Re-exports§
pub use pallet::*;
Modules§
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet.