mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
Define RangeInclusiveExt (#2037)
* Define RangeInclusiveExt * Use RangeInclusiveExt * Add docs
This commit is contained in:
committed by
Bastian Köcher
parent
ea39f4c0d2
commit
b8f4086095
@@ -115,22 +115,6 @@ pub enum CallInfo {
|
||||
ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo),
|
||||
}
|
||||
|
||||
impl CallInfo {
|
||||
/// Returns number of messages, bundled with this transaction.
|
||||
pub fn bundled_messages(&self) -> MessageNonce {
|
||||
let bundled_range = match *self {
|
||||
Self::ReceiveMessagesProof(ref info) => &info.base.bundled_range,
|
||||
Self::ReceiveMessagesDeliveryProof(ref info) => &info.0.bundled_range,
|
||||
};
|
||||
|
||||
bundled_range
|
||||
.end()
|
||||
.checked_sub(*bundled_range.start())
|
||||
.map(|d| d.saturating_add(1))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper struct that provides methods for working with a call supported by `CallInfo`.
|
||||
pub struct CallHelper<T: Config<I>, I: 'static> {
|
||||
pub _phantom_data: sp_std::marker::PhantomData<(T, I)>,
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::messages_call_ext::{
|
||||
};
|
||||
use bp_messages::LaneId;
|
||||
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
|
||||
use bp_runtime::StaticStrProvider;
|
||||
use bp_runtime::{RangeInclusiveExt, StaticStrProvider};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo},
|
||||
@@ -319,9 +319,9 @@ where
|
||||
if let Some(parsed_call) = parsed_call {
|
||||
// we give delivery transactions some boost, that depends on number of messages inside
|
||||
let messages_call_info = parsed_call.messages_call_info();
|
||||
if let MessagesCallInfo::ReceiveMessagesProof(_) = messages_call_info {
|
||||
if let MessagesCallInfo::ReceiveMessagesProof(info) = messages_call_info {
|
||||
// compute total number of messages in transaction
|
||||
let bundled_messages = messages_call_info.bundled_messages();
|
||||
let bundled_messages = info.base.bundled_range.checked_len().unwrap_or(0);
|
||||
|
||||
// a quick check to avoid invalid high-priority transactions
|
||||
if bundled_messages <= Runtime::MaxUnconfirmedMessagesAtInboundLane::get() {
|
||||
|
||||
Reference in New Issue
Block a user