mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
Return cumulative dispatch weight of messages from the messageLane_proveMessages (#469)
* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes * fixed typo
This commit is contained in:
committed by
Bastian Köcher
parent
51f39c4427
commit
ef9357596f
@@ -206,6 +206,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
DenyUnsafe::No,
|
||||
)));
|
||||
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
|
||||
client.clone(),
|
||||
backend.clone(),
|
||||
Arc::new(RialtoMessageLaneKeys),
|
||||
)));
|
||||
|
||||
@@ -37,6 +37,7 @@ pub mod millau;
|
||||
pub mod millau_messages;
|
||||
pub mod rialto_poa;
|
||||
|
||||
use codec::Decode;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
@@ -702,6 +703,36 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: runtime should support several chains (https://github.com/paritytech/parity-bridges-common/issues/457)
|
||||
impl bp_message_lane::OutboundLaneApi<Block> for Runtime {
|
||||
fn messages_dispatch_weight(lane: bp_message_lane::LaneId, begin: bp_message_lane::MessageNonce, end: bp_message_lane::MessageNonce) -> Weight {
|
||||
(begin..=end)
|
||||
.filter_map(|nonce| BridgeMillauMessageLane::outbound_message_payload(lane, nonce))
|
||||
.filter_map(|encoded_payload| millau_messages::ToMillauMessagePayload::decode(&mut &encoded_payload[..]).ok())
|
||||
.map(|decoded_payload| decoded_payload.weight)
|
||||
.fold(0, |sum, weight| sum.saturating_add(weight))
|
||||
}
|
||||
|
||||
fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeMillauMessageLane::outbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_generated_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeMillauMessageLane::outbound_latest_generated_nonce(lane)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: runtime should support several chains (https://github.com/paritytech/parity-bridges-common/issues/457)
|
||||
impl bp_message_lane::InboundLaneApi<Block> for Runtime {
|
||||
fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeMillauMessageLane::inbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_confirmed_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeMillauMessageLane::inbound_latest_confirmed_nonce(lane)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn dispatch_benchmark(
|
||||
|
||||
Reference in New Issue
Block a user