mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01: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
@@ -222,6 +222,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
finality_proof_provider.clone(),
|
||||
)));
|
||||
io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new(
|
||||
client.clone(),
|
||||
backend.clone(),
|
||||
Arc::new(MillauMessageLaneKeys),
|
||||
)));
|
||||
|
||||
@@ -31,6 +31,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
pub mod rialto;
|
||||
pub mod rialto_messages;
|
||||
|
||||
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;
|
||||
@@ -538,4 +539,34 @@ impl_runtime_apis! {
|
||||
BridgeRialto::is_finalized_header(hash)
|
||||
}
|
||||
}
|
||||
|
||||
// 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| BridgeRialtoMessageLane::outbound_message_payload(lane, nonce))
|
||||
.filter_map(|encoded_payload| rialto_messages::ToRialtoMessagePayload::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 {
|
||||
BridgeRialtoMessageLane::outbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_generated_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::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 {
|
||||
BridgeRialtoMessageLane::inbound_latest_received_nonce(lane)
|
||||
}
|
||||
|
||||
fn latest_confirmed_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce {
|
||||
BridgeRialtoMessageLane::inbound_latest_confirmed_nonce(lane)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user