bp_runtime/messages.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Parity Bridges Common.
3
4// Parity Bridges Common is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Parity Bridges Common is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
16
17//! Primitives that may be used by different message delivery and dispatch mechanisms.
18
19use codec::{Decode, DecodeWithMemTracking, Encode};
20use frame_support::weights::Weight;
21use scale_info::TypeInfo;
22use sp_runtime::RuntimeDebug;
23
24/// Message dispatch result.
25#[derive(Encode, Decode, DecodeWithMemTracking, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
26pub struct MessageDispatchResult<DispatchLevelResult> {
27 /// Unspent dispatch weight. This weight that will be deducted from total delivery transaction
28 /// weight, thus reducing the transaction cost. This shall not be zero in (at least) two cases:
29 ///
30 /// 1) if message has been dispatched successfully, but post-dispatch weight is less than the
31 /// weight, declared by the message sender;
32 /// 2) if message has not been dispatched at all.
33 pub unspent_weight: Weight,
34 /// Fine-grained result of single message dispatch (for better diagnostic purposes)
35 pub dispatch_level_result: DispatchLevelResult,
36}