pallet-message-queue: add queue pausing (#14318)

* pallet-message-queue: add queue pausing

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix build

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Remove check

Otherwise it would not start servicing queues that started paused
and became unpaused afterwards.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-06-28 10:58:31 +02:00
committed by GitHub
parent 2119c80225
commit 4249643df2
8 changed files with 269 additions and 63 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ pub use preimages::{Bounded, BoundedInline, FetchResult, Hash, QueryPreimage, St
mod messages;
pub use messages::{
EnqueueMessage, ExecuteOverweightError, Footprint, NoopServiceQueues, ProcessMessage,
ProcessMessageError, ServiceQueues, TransformOrigin,
ProcessMessageError, QueuePausedQuery, ServiceQueues, TransformOrigin,
};
#[cfg(feature = "try-runtime")]
@@ -69,8 +69,18 @@ pub trait ProcessMessage {
pub enum ExecuteOverweightError {
/// The referenced message was not found.
NotFound,
/// The message was already processed.
///
/// This can be treated as success condition.
AlreadyProcessed,
/// The available weight was insufficient to execute the message.
InsufficientWeight,
/// The queue is paused and no message can be executed from it.
///
/// This can change at any time and may resolve in the future by re-trying.
QueuePaused,
/// An unspecified error.
Other,
}
/// Can service queues and execute overweight messages.
@@ -220,3 +230,15 @@ where
E::footprint(O::get())
}
}
/// Provides information on paused queues.
pub trait QueuePausedQuery<Origin> {
/// Whether this queue is paused.
fn is_paused(origin: &Origin) -> bool;
}
impl<Origin> QueuePausedQuery<Origin> for () {
fn is_paused(_: &Origin) -> bool {
false
}
}