Struct pallet_message_queue::pallet::Pallet
source · pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn reap_page(
origin: OriginFor<T>,
message_origin: MessageOriginOf<T>,
page_index: u32
) -> DispatchResult
pub fn reap_page(
origin: OriginFor<T>,
message_origin: MessageOriginOf<T>,
page_index: u32
) -> DispatchResult
Remove a page which has no more messages remaining to be processed or is stale.
sourcepub fn execute_overweight(
origin: OriginFor<T>,
message_origin: MessageOriginOf<T>,
page: u32,
index: T::Size,
weight_limit: Weight
) -> DispatchResultWithPostInfo
pub fn execute_overweight(
origin: OriginFor<T>,
message_origin: MessageOriginOf<T>,
page: u32,
index: T::Size,
weight_limit: Weight
) -> DispatchResultWithPostInfo
Execute an overweight message.
origin
: Must beSigned
.message_origin
: The origin from which the message to be executed arrived.page
: The page in the queue in which the message to be executed is sitting.index
: The index into the queue of the message to be executed.weight_limit
: The maximum amount of weight allowed to be consumed in the execution of the message.
Benchmark complexity considerations: O(index + weight_limit).
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn do_execute_overweight(
origin: MessageOriginOf<T>,
page_index: u32,
index: T::Size,
weight_limit: Weight
) -> Result<Weight, Error<T>>
pub fn do_execute_overweight(
origin: MessageOriginOf<T>,
page_index: u32,
index: T::Size,
weight_limit: Weight
) -> Result<Weight, Error<T>>
Try to execute a single message that was marked as overweight.
The weight_limit
is the weight that can be consumed to execute the message. The base
weight of the function it self must be measured by the caller.
Examples found in repository?
src/lib.rs (line 1262)
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
fn execute_overweight(
weight_limit: Weight,
(message_origin, page, index): Self::OverweightMessageAddress,
) -> Result<Weight, ExecuteOverweightError> {
let mut weight = WeightMeter::from_limit(weight_limit);
if !weight.check_accrue(
T::WeightInfo::execute_overweight_page_removed()
.max(T::WeightInfo::execute_overweight_page_updated()),
) {
return Err(ExecuteOverweightError::InsufficientWeight)
}
Pallet::<T>::do_execute_overweight(message_origin, page, index, weight.remaining()).map_err(
|e| match e {
Error::<T>::InsufficientWeight => ExecuteOverweightError::InsufficientWeight,
_ => ExecuteOverweightError::NotFound,
},
)
}
sourcepub fn debug_info() -> String
pub fn debug_info() -> String
Print the pages in each queue and the messages in each page.
Processed messages are prefixed with a *
and the current begin
ning page with a >
.
Example output
queue Here:
page 0: []
> page 1: []
page 2: ["\0weight=4", "\0c", ]
page 3: ["\0bigbig 1", ]
page 4: ["\0bigbig 2", ]
page 5: ["\0bigbig 3", ]
Trait Implementations§
source§impl<T: Config> EnqueueMessage<<<T as Config>::MessageProcessor as ProcessMessage>::Origin> for Pallet<T>
impl<T: Config> EnqueueMessage<<<T as Config>::MessageProcessor as ProcessMessage>::Origin> for Pallet<T>
§type MaxMessageLen = MaxMessageLen<<<T as Config>::MessageProcessor as ProcessMessage>::Origin, <T as Config>::Size, <T as Config>::HeapSize>
type MaxMessageLen = MaxMessageLen<<<T as Config>::MessageProcessor as ProcessMessage>::Origin, <T as Config>::Size, <T as Config>::HeapSize>
The maximal length any enqueued message may have.
source§fn enqueue_message(
message: BoundedSlice<'_, u8, Self::MaxMessageLen>,
origin: <T::MessageProcessor as ProcessMessage>::Origin
)
fn enqueue_message(
message: BoundedSlice<'_, u8, Self::MaxMessageLen>,
origin: <T::MessageProcessor as ProcessMessage>::Origin
)
Enqueue a single
message
from a specific origin
.source§fn enqueue_messages<'a>(
messages: impl Iterator<Item = BoundedSlice<'a, u8, Self::MaxMessageLen>>,
origin: <T::MessageProcessor as ProcessMessage>::Origin
)
fn enqueue_messages<'a>(
messages: impl Iterator<Item = BoundedSlice<'a, u8, Self::MaxMessageLen>>,
origin: <T::MessageProcessor as ProcessMessage>::Origin
)
Enqueue multiple
messages
from a specific origin
.source§fn sweep_queue(origin: MessageOriginOf<T>)
fn sweep_queue(origin: MessageOriginOf<T>)
Any remaining unprocessed messages should happen only lazily, not proactively.
source§fn footprint(origin: MessageOriginOf<T>) -> Footprint
fn footprint(origin: MessageOriginOf<T>) -> Footprint
Return the state footprint of the given queue.
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
source§fn current_storage_version() -> StorageVersion
fn current_storage_version() -> StorageVersion
Returns the current storage version as supported by the pallet.
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Returns the on-chain storage version of the pallet as stored in the storage.
source§impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Check all assumptions about crate::Config
.
source§fn on_initialize(_n: BlockNumberFor<T>) -> Weight
fn on_initialize(_n: BlockNumberFor<T>) -> Weight
The block is being initialized. Implement to have something happen. Read more
source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
The block is being finalized. Implement to have something happen.
source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
This will be run when the block is being finalized (before
on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists.source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Implementing this function on a module allows you to perform long-running tasks
that make (by default) validators generate transactions that feed results
of those long-running computations back on chain. Read more
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Run integrity test. Read more
source§impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
source§fn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
This function is being called after every block import (when fully synced). Read more
source§impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
The block is being finalized. Implement to have something happen. Read more
source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
Something that should happen at genesis.
source§impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
The block is being finalized.
Implement to have something happen in case there is leftover weight.
Check the passed
remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read moresource§impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
Name of the Rust module containing the pallet.
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Version of the crate containing the pallet.
source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
source§impl<T> PartialEq<Pallet<T>> for Pallet<T>
impl<T> PartialEq<Pallet<T>> for Pallet<T>
source§impl<T: Config> ServiceQueues for Pallet<T>
impl<T: Config> ServiceQueues for Pallet<T>
source§fn execute_overweight(
weight_limit: Weight,
(message_origin, page, index): Self::OverweightMessageAddress
) -> Result<Weight, ExecuteOverweightError>
fn execute_overweight(
weight_limit: Weight,
(message_origin, page, index): Self::OverweightMessageAddress
) -> Result<Weight, ExecuteOverweightError>
Execute a single overweight message.
The weight limit must be enough for execute_overweight
and the message execution itself.
§type OverweightMessageAddress = (<<T as Config>::MessageProcessor as ProcessMessage>::Origin, u32, <T as Config>::Size)
type OverweightMessageAddress = (<<T as Config>::MessageProcessor as ProcessMessage>::Origin, u32, <T as Config>::Size)
Addresses a specific overweight message.
source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo> ⓘ
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
Returns a
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
fn migrate(db_weight: &RuntimeDbWeight) -> Weight
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.