Skip to content

Commit

Permalink
Moved send_packet impls to its own mod
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 committed Aug 4, 2023
1 parent 610e571 commit e0b5f22
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod channel;
pub mod consensus_state;
pub mod packet_commitments;
pub mod received_packet;
pub mod send_packet;
pub mod status;
pub mod unreceived_packets;
pub mod write_ack;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use async_trait::async_trait;

use ibc_relayer_components::chain::traits::queries::send_packet::CanQuerySendPacketsFromSequences;

use crate::one_for_all::traits::chain::{OfaChainTypes, OfaIbcChain};
use crate::one_for_all::types::chain::OfaChainWrapper;
use crate::std_prelude::*;

#[async_trait]
impl<Chain, Counterparty> CanQuerySendPacketsFromSequences<OfaChainWrapper<Counterparty>>
for OfaChainWrapper<Chain>
where
Chain: OfaIbcChain<Counterparty> + OfaChainTypes,
Counterparty: OfaIbcChain<Chain>,
{
/// Given a list of sequences, a channel and port will query a list of outgoing
/// packets which have not been relayed.
async fn query_send_packets_from_sequences(
&self,
channel_id: &Self::ChannelId,
port_id: &Self::PortId,
counterparty_channel_id: &Counterparty::ChannelId,
counterparty_port_id: &Counterparty::PortId,
sequences: &[Self::Sequence],
// The height is given to query the packets from a specific height.
// This height should be the same as the query height from the
// `CanQueryPacketCommitments` made on the same chain.
height: &Self::Height,
) -> Result<Vec<Self::OutgoingPacket>, Self::Error> {
let send_packets = self
.chain
.query_send_packets_from_sequences(
channel_id,
port_id,
counterparty_channel_id,
counterparty_port_id,
sequences,
height,
)
.await?;
Ok(send_packets)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use async_trait::async_trait;

use ibc_relayer_components::chain::traits::queries::send_packet::CanQuerySendPacketsFromSequences;
use ibc_relayer_components::chain::traits::queries::unreceived_packets::CanQueryUnreceivedPacketSequences;

use crate::one_for_all::traits::chain::{OfaChainTypes, OfaIbcChain};
Expand Down Expand Up @@ -31,39 +30,3 @@ where
Ok(unreceived_packet_sequences)
}
}

#[async_trait]
impl<Chain, Counterparty> CanQuerySendPacketsFromSequences<OfaChainWrapper<Counterparty>>
for OfaChainWrapper<Chain>
where
Chain: OfaIbcChain<Counterparty> + OfaChainTypes,
Counterparty: OfaIbcChain<Chain>,
{
/// Given a list of sequences, a channel and port will query a list of outgoing
/// packets which have not been relayed.
async fn query_send_packets_from_sequences(
&self,
channel_id: &Self::ChannelId,
port_id: &Self::PortId,
counterparty_channel_id: &Counterparty::ChannelId,
counterparty_port_id: &Counterparty::PortId,
sequences: &[Self::Sequence],
// The height is given to query the packets from a specific height.
// This height should be the same as the query height from the
// `CanQueryPacketCommitments` made on the same chain.
height: &Self::Height,
) -> Result<Vec<Self::OutgoingPacket>, Self::Error> {
let send_packets = self
.chain
.query_send_packets_from_sequences(
channel_id,
port_id,
counterparty_channel_id,
counterparty_port_id,
sequences,
height,
)
.await?;
Ok(send_packets)
}
}

0 comments on commit e0b5f22

Please sign in to comment.