Trait gear_common::storage::Messenger

source ·
pub trait Messenger {
Show 21 associated items type BlockNumber; type Capacity; type Error: Debug + DequeueError + MailboxError + WaitlistError; type OutputError: From<Self::Error> + Debug; type MailboxFirstKey; type MailboxSecondKey; type MailboxedMessage; type QueuedDispatch; type DelayedDispatch; type WaitlistFirstKey; type WaitlistSecondKey; type WaitlistedMessage; type DispatchStashKey; type Sent: Counter<Value = Self::Capacity>; type Dequeued: Counter<Value = Self::Capacity>; type QueueProcessing: Toggler; type Queue: Queue<Value = Self::QueuedDispatch, Error = Self::Error, OutputError = Self::OutputError> + Counted<Length = Self::Capacity> + IterableMap<Result<Self::QueuedDispatch, Self::OutputError>>; type Mailbox: Mailbox<Key1 = Self::MailboxFirstKey, Key2 = Self::MailboxSecondKey, Value = Self::MailboxedMessage, BlockNumber = Self::BlockNumber, Error = Self::Error, OutputError = Self::OutputError> + CountedByKey<Key = Self::MailboxFirstKey, Length = usize> + IterableMap<(Self::MailboxedMessage, Interval<Self::BlockNumber>)> + IterableByKeyMap<(Self::MailboxedMessage, Interval<Self::BlockNumber>), Key = Self::MailboxFirstKey>; type Waitlist: Waitlist<Key1 = Self::WaitlistFirstKey, Key2 = Self::WaitlistSecondKey, Value = Self::WaitlistedMessage, BlockNumber = Self::BlockNumber, Error = Self::Error, OutputError = Self::OutputError> + CountedByKey<Key = Self::WaitlistFirstKey, Length = usize> + IterableMap<(Self::WaitlistedMessage, Interval<Self::BlockNumber>)> + IterableByKeyMap<(Self::WaitlistedMessage, Interval<Self::BlockNumber>), Key = Self::WaitlistFirstKey>; type DispatchStash: MapStorage<Key = Self::DispatchStashKey, Value = (Self::DelayedDispatch, Interval<Self::BlockNumber>)>; // Provided method fn reset() { ... }
}
Expand description

Represents messenger’s logic of centralized message processing behavior.

Required Associated Types§

source

type BlockNumber

Block number type of the messenger.

source

type Capacity

Capacity of the messenger.

This type defines length type of the queue, sent and dequeued messages within same block amount type.

source

type Error: Debug + DequeueError + MailboxError + WaitlistError

Inner error type generated by gear’s storage types.

source

type OutputError: From<Self::Error> + Debug

Output error of each storage algorithm.

Implements From<Self::Error> to be able to return any required error type.

source

type MailboxFirstKey

First key of the mailbox storage.

Present to clarify compiler behavior over associated types.

source

type MailboxSecondKey

Second key of the mailbox storage.

Present to clarify compiler behavior over associated types.

source

type MailboxedMessage

Stored values type for Self::Mailbox.

Present to clarify compiler behavior over associated types.

source

type QueuedDispatch

Stored values type for Self::Queue.

Present to clarify compiler behavior over associated types.

source

type DelayedDispatch

Stored values type for Self::DispatchStash.

Present to clarify compiler behavior over associated types.

source

type WaitlistFirstKey

First key of the waitlist storage.

Present to clarify compiler behavior over associated types.

source

type WaitlistSecondKey

Second key of the waitlist storage.

Present to clarify compiler behavior over associated types.

source

type WaitlistedMessage

Stored values type for Self::Waitlist.

Present to clarify compiler behavior over associated types.

source

type DispatchStashKey

Key for value types for Self::DispatchStash.

Present to clarify compiler behavior over associated types.

source

type Sent: Counter<Value = Self::Capacity>

Amount of messages sent from outside (from users) within the current block.

Used as local counter for MessageId generation.

source

type Dequeued: Counter<Value = Self::Capacity>

Amount of messages dequeued with the current block.

Used for depositing informational event about how much messages were took from queue in process_queue execution.

source

type QueueProcessing: Toggler

Allowance of queue processing.

Used for checking could process_queue continue it’s execution. Execution finishes, once message requeued at the end of the queue, because it alerts, that this execution exceed gas allowance of the current block by gear’s processing algorithm.

source

type Queue: Queue<Value = Self::QueuedDispatch, Error = Self::Error, OutputError = Self::OutputError> + Counted<Length = Self::Capacity> + IterableMap<Result<Self::QueuedDispatch, Self::OutputError>>

Gear message queue.

Message queue contains only messages addressed to programs. Messages from queue process on idle of each block in process_queue, function, except case of runtime upgrade - then processing skipped.

source

type Mailbox: Mailbox<Key1 = Self::MailboxFirstKey, Key2 = Self::MailboxSecondKey, Value = Self::MailboxedMessage, BlockNumber = Self::BlockNumber, Error = Self::Error, OutputError = Self::OutputError> + CountedByKey<Key = Self::MailboxFirstKey, Length = usize> + IterableMap<(Self::MailboxedMessage, Interval<Self::BlockNumber>)> + IterableByKeyMap<(Self::MailboxedMessage, Interval<Self::BlockNumber>), Key = Self::MailboxFirstKey>

Gear mailbox.

Mailbox contains only messages addressed to user accounts. Any address meant as user account if it’s not program id.

Only mailbox owner (user with message’s destination address) can claim value from the message, removing it afterward, or claim and send reply on received message, if it still present (#642).

source

type Waitlist: Waitlist<Key1 = Self::WaitlistFirstKey, Key2 = Self::WaitlistSecondKey, Value = Self::WaitlistedMessage, BlockNumber = Self::BlockNumber, Error = Self::Error, OutputError = Self::OutputError> + CountedByKey<Key = Self::WaitlistFirstKey, Length = usize> + IterableMap<(Self::WaitlistedMessage, Interval<Self::BlockNumber>)> + IterableByKeyMap<(Self::WaitlistedMessage, Interval<Self::BlockNumber>), Key = Self::WaitlistFirstKey>

Gear waitlist.

Waitlist contains messages, which execution should be delayed for some logic.

Message can be inserted into waitlist only in these cases:

  1. Destination program called gr_wait while was executing this message, so only this program can remove and requeue it by gr_wake call in any execution.
  2. The message sent to program, that hadn’t finished its initialization, and will be automatically removed once result of initialization would be available.
  3. Restored after resuming paused programs. On pause we collect waitlist content addressed to the program, removing it afterwards. On resume, user should provide the same content to be able to unpause program, which gonna be added into waitlist again.

More cases may be considered in future.

Gear runtime also charges rent for holding in waitlist. Note, that system can remove message from waitlist, if it couldn’t pay rent for holding there further. For details, see pallet-gear-scheduler.

source

type DispatchStash: MapStorage<Key = Self::DispatchStashKey, Value = (Self::DelayedDispatch, Interval<Self::BlockNumber>)>

Provided Methods§

source

fn reset()

Resets all related to messenger storages.

It’s a temporary production solution to avoid DB migrations and would be available for test purposes only in the future.

Object Safety§

This trait is not object safe.

Implementors§