DeliveryConfirmationPayments trait for paying relayer rewards at the source chain (#1653)

* DeliveryConfirmationPayments

* ref proper PR in TODO
This commit is contained in:
Svyatoslav Nikolsky
2022-12-06 16:09:21 +03:00
committed by Bastian Köcher
parent 7014046485
commit aeeb53343e
11 changed files with 118 additions and 93 deletions
@@ -125,6 +125,37 @@ impl<SenderOrigin, AccountId> MessageDeliveryAndDispatchPayment<SenderOrigin, Ac
}
}
/// Manages payments that are happening at the source chain during delivery confirmation
/// transaction.
pub trait DeliveryConfirmationPayments<AccountId> {
/// Error type.
type Error: Debug + Into<&'static str>;
/// Pay rewards for delivering messages to the given relayers.
///
/// The implementation may also choose to pay reward to the `confirmation_relayer`, which is
/// a relayer that has submitted delivery confirmation transaction.
fn pay_reward(
lane_id: LaneId,
messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
confirmation_relayer: &AccountId,
received_range: &RangeInclusive<MessageNonce>,
);
}
impl<AccountId> DeliveryConfirmationPayments<AccountId> for () {
type Error = &'static str;
fn pay_reward(
_lane_id: LaneId,
_messages_relayers: VecDeque<UnrewardedRelayer<AccountId>>,
_confirmation_relayer: &AccountId,
_received_range: &RangeInclusive<MessageNonce>,
) {
// this implementation is not rewarding relayers at all
}
}
/// Send message artifacts.
#[derive(Eq, RuntimeDebug, PartialEq)]
pub struct SendMessageArtifacts {