mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 19:11:02 +00:00
Reintroduce msg dispatch status reporting (#2027)
* Use an actual Result inside MessageDispatchResult We need this in order to distinguish between Ok and Err * Revert #1660 * Fixes + simplifications * Implement review suggestions
This commit is contained in:
committed by
Bastian Köcher
parent
4d29753f73
commit
3b968a2aba
@@ -101,6 +101,7 @@ impl<T: Config<I>, I: 'static> MaxEncodedLen for StoredInboundLaneData<T, I> {
|
||||
fn max_encoded_len() -> usize {
|
||||
InboundLaneData::<T::InboundRelayer>::encoded_size_hint(
|
||||
T::MaxUnrewardedRelayerEntriesAtInboundLane::get() as usize,
|
||||
T::MaxUnconfirmedMessagesAtInboundLane::get() as usize,
|
||||
)
|
||||
.unwrap_or(usize::MAX)
|
||||
}
|
||||
@@ -154,6 +155,9 @@ impl<S: InboundLaneStorage> InboundLane<S> {
|
||||
// overlap.
|
||||
match data.relayers.front_mut() {
|
||||
Some(entry) if entry.messages.begin < new_confirmed_nonce => {
|
||||
entry.messages.dispatch_results = entry.messages.dispatch_results
|
||||
[(new_confirmed_nonce + 1 - entry.messages.begin) as usize..]
|
||||
.to_bitvec();
|
||||
entry.messages.begin = new_confirmed_nonce + 1;
|
||||
},
|
||||
_ => {},
|
||||
@@ -170,7 +174,7 @@ impl<S: InboundLaneStorage> InboundLane<S> {
|
||||
relayer_at_this_chain: &AccountId,
|
||||
nonce: MessageNonce,
|
||||
message_data: DispatchMessageData<Dispatch::DispatchPayload>,
|
||||
) -> ReceivalResult<Dispatch::DispatchLevelResult> {
|
||||
) -> ReceivalResult<Dispatch::DispatchError> {
|
||||
let mut data = self.storage.data();
|
||||
let is_correct_message = nonce == data.last_delivered_nonce() + 1;
|
||||
if !is_correct_message {
|
||||
@@ -198,19 +202,20 @@ impl<S: InboundLaneStorage> InboundLane<S> {
|
||||
);
|
||||
|
||||
// now let's update inbound lane storage
|
||||
let push_new = match data.relayers.back_mut() {
|
||||
match data.relayers.back_mut() {
|
||||
Some(entry) if entry.relayer == *relayer_at_bridged_chain => {
|
||||
entry.messages.note_dispatched_message();
|
||||
false
|
||||
entry.messages.note_dispatched_message(dispatch_result.dispatch_result.is_ok());
|
||||
},
|
||||
_ => {
|
||||
data.relayers.push_back(UnrewardedRelayer {
|
||||
relayer: relayer_at_bridged_chain.clone(),
|
||||
messages: DeliveredMessages::new(
|
||||
nonce,
|
||||
dispatch_result.dispatch_result.is_ok(),
|
||||
),
|
||||
});
|
||||
},
|
||||
_ => true,
|
||||
};
|
||||
if push_new {
|
||||
data.relayers.push_back(UnrewardedRelayer {
|
||||
relayer: (*relayer_at_bridged_chain).clone(),
|
||||
messages: DeliveredMessages::new(nonce),
|
||||
});
|
||||
}
|
||||
self.storage.set_data(data);
|
||||
|
||||
ReceivalResult::Dispatched(dispatch_result)
|
||||
|
||||
Reference in New Issue
Block a user