mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
MaxValues for OutboundLanes map (#1871)
This commit is contained in:
committed by
Bastian Köcher
parent
89bb368e45
commit
d8764450c9
@@ -583,8 +583,14 @@ pub mod pallet {
|
||||
|
||||
/// Map of lane id => outbound lane data.
|
||||
#[pallet::storage]
|
||||
pub type OutboundLanes<T: Config<I>, I: 'static = ()> =
|
||||
StorageMap<_, Blake2_128Concat, LaneId, OutboundLaneData, ValueQuery>;
|
||||
pub type OutboundLanes<T: Config<I>, I: 'static = ()> = StorageMap<
|
||||
Hasher = Blake2_128Concat,
|
||||
Key = LaneId,
|
||||
Value = OutboundLaneData,
|
||||
QueryKind = ValueQuery,
|
||||
OnEmpty = GetDefault,
|
||||
MaxValues = MaybeOutboundLanesCount<T, I>,
|
||||
>;
|
||||
|
||||
/// All queued outbound messages.
|
||||
#[pallet::storage]
|
||||
@@ -648,6 +654,15 @@ pub mod pallet {
|
||||
InboundLanes::<T, I>::get(lane).0
|
||||
}
|
||||
}
|
||||
|
||||
/// Get-parameter that returns number of active outbound lanes that the pallet maintains.
|
||||
pub struct MaybeOutboundLanesCount<T, I>(PhantomData<(T, I)>);
|
||||
|
||||
impl<T: Config<I>, I: 'static> Get<Option<u32>> for MaybeOutboundLanesCount<T, I> {
|
||||
fn get() -> Option<u32> {
|
||||
Some(T::ActiveOutboundLanes::get().len() as u32)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, I> bp_messages::source_chain::MessagesBridge<T::RuntimeOrigin, T::OutboundPayload>
|
||||
@@ -1962,4 +1977,12 @@ mod tests {
|
||||
MessagesOperatingMode::Basic(BasicOperatingMode::Normal),
|
||||
MessagesOperatingMode::Basic(BasicOperatingMode::Halted)
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn maybe_outbound_lanes_count_returns_correct_value() {
|
||||
assert_eq!(
|
||||
MaybeOutboundLanesCount::<TestRuntime, ()>::get(),
|
||||
Some(mock::ActiveOutboundLanes::get().len() as u32)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user