mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
[polkadot-staging] Separate send_message() validations (#2795)
* Fix xcm-bridge-hub build * Move send_message definition to MessagesBridge impl * Make send_message infallible * Split `MessagesBridge` into 2 phases Split `MessagesBridge` into 2 phases: - message validation - message sending
This commit is contained in:
committed by
Bastian Köcher
parent
9de0788222
commit
241a3b415f
@@ -125,22 +125,22 @@ pub trait MessagesBridge<Payload> {
|
||||
/// Error type.
|
||||
type Error: Debug;
|
||||
|
||||
/// Intermediary structure returned by `validate_message()`.
|
||||
///
|
||||
/// It can than be passed to `send_message()` in order to actually send the message
|
||||
/// on the bridge.
|
||||
type SendMessageArgs;
|
||||
|
||||
/// Check if the message can be sent over the bridge.
|
||||
fn validate_message(
|
||||
lane: LaneId,
|
||||
message: &Payload,
|
||||
) -> Result<Self::SendMessageArgs, Self::Error>;
|
||||
|
||||
/// Send message over the bridge.
|
||||
///
|
||||
/// Returns unique message nonce or error if send has failed.
|
||||
fn send_message(lane: LaneId, message: Payload) -> Result<SendMessageArtifacts, Self::Error>;
|
||||
}
|
||||
|
||||
/// Bridge that does nothing when message is being sent.
|
||||
#[derive(Eq, RuntimeDebug, PartialEq)]
|
||||
pub struct NoopMessagesBridge;
|
||||
|
||||
impl<Payload> MessagesBridge<Payload> for NoopMessagesBridge {
|
||||
type Error = &'static str;
|
||||
|
||||
fn send_message(_lane: LaneId, _message: Payload) -> Result<SendMessageArtifacts, Self::Error> {
|
||||
Ok(SendMessageArtifacts { nonce: 0, enqueued_messages: 0 })
|
||||
}
|
||||
fn send_message(message: Self::SendMessageArgs) -> SendMessageArtifacts;
|
||||
}
|
||||
|
||||
/// Structure that may be used in place of `TargetHeaderChain` and
|
||||
|
||||
Reference in New Issue
Block a user