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§
sourcetype BlockNumber
type BlockNumber
Block number type of the messenger.
sourcetype Capacity
type Capacity
Capacity of the messenger.
This type defines length type of the queue, sent and dequeued messages within same block amount type.
sourcetype Error: Debug + DequeueError + MailboxError + WaitlistError
type Error: Debug + DequeueError + MailboxError + WaitlistError
Inner error type generated by gear’s storage types.
sourcetype OutputError: From<Self::Error> + Debug
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.
sourcetype MailboxFirstKey
type MailboxFirstKey
First key of the mailbox storage.
Present to clarify compiler behavior over associated types.
sourcetype MailboxSecondKey
type MailboxSecondKey
Second key of the mailbox storage.
Present to clarify compiler behavior over associated types.
sourcetype MailboxedMessage
type MailboxedMessage
Stored values type for Self::Mailbox
.
Present to clarify compiler behavior over associated types.
sourcetype QueuedDispatch
type QueuedDispatch
Stored values type for Self::Queue
.
Present to clarify compiler behavior over associated types.
sourcetype DelayedDispatch
type DelayedDispatch
Stored values type for Self::DispatchStash
.
Present to clarify compiler behavior over associated types.
sourcetype WaitlistFirstKey
type WaitlistFirstKey
First key of the waitlist storage.
Present to clarify compiler behavior over associated types.
sourcetype WaitlistSecondKey
type WaitlistSecondKey
Second key of the waitlist storage.
Present to clarify compiler behavior over associated types.
sourcetype WaitlistedMessage
type WaitlistedMessage
Stored values type for Self::Waitlist
.
Present to clarify compiler behavior over associated types.
sourcetype DispatchStashKey
type DispatchStashKey
Key for value types for Self::DispatchStash
.
Present to clarify compiler behavior over associated types.
sourcetype Sent: Counter<Value = Self::Capacity>
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.
sourcetype Dequeued: Counter<Value = Self::Capacity>
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.
sourcetype QueueProcessing: Toggler
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.
sourcetype Queue: Queue<Value = Self::QueuedDispatch, Error = Self::Error, OutputError = Self::OutputError> + Counted<Length = Self::Capacity> + IterableMap<Result<Self::QueuedDispatch, Self::OutputError>>
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.
sourcetype 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 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).
sourcetype 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 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:
- Destination program called
gr_wait
while was executing this message, so only this program can remove and requeue it bygr_wake
call in any execution. - The message sent to program, that hadn’t finished its initialization, and will be automatically removed once result of initialization would be available.
- 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
.