mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
read latest_generated_nonce directly from storage (#1260)
This commit is contained in:
committed by
Bastian Köcher
parent
741484214e
commit
c21217a282
@@ -28,7 +28,10 @@ use crate::{
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState};
|
||||
use bp_messages::{
|
||||
storage_keys::outbound_lane_data_key, LaneId, MessageNonce, OutboundLaneData,
|
||||
UnrewardedRelayersState,
|
||||
};
|
||||
use bridge_runtime_common::messages::{
|
||||
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
|
||||
};
|
||||
@@ -126,16 +129,19 @@ where
|
||||
&self,
|
||||
id: SourceHeaderIdOf<MessageLaneAdapter<P>>,
|
||||
) -> Result<(SourceHeaderIdOf<MessageLaneAdapter<P>>, MessageNonce), SubstrateError> {
|
||||
let encoded_response = self
|
||||
let outbound_lane_data: Option<OutboundLaneData> = self
|
||||
.client
|
||||
.state_call(
|
||||
P::TargetChain::TO_CHAIN_LATEST_GENERATED_NONCE_METHOD.into(),
|
||||
Bytes(self.lane_id.encode()),
|
||||
.storage_value(
|
||||
outbound_lane_data_key(
|
||||
P::TargetChain::WITH_CHAIN_MESSAGES_PALLET_NAME,
|
||||
&self.lane_id,
|
||||
),
|
||||
Some(id.1),
|
||||
)
|
||||
.await?;
|
||||
let latest_generated_nonce: MessageNonce = Decode::decode(&mut &encoded_response.0[..])
|
||||
.map_err(SubstrateError::ResponseParseFailed)?;
|
||||
// lane data missing from the storage is fine until first message is sent
|
||||
let latest_generated_nonce =
|
||||
outbound_lane_data.map(|data| data.latest_generated_nonce).unwrap_or(0);
|
||||
Ok((id, latest_generated_nonce))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user