pub fn resolve<ChainA: ChainHandle, ChainB: ChainHandle>(
    ctx: ResolveContext,
    channel: &Channel<ChainA, ChainB>,
) -> Result<Version, ChannelError> {
    let port_id = channel.dst_port_id();

    match ctx {
        ResolveContext::ChanOpenInit => {
            // When the channel is uninitialized, the relayer will use the
            // default channel version, depending on the port id.
            default_by_port(port_id)
        }
        ResolveContext::Other => {
            // Resolve the version by querying the application version on destination chain
            let dst_chain_id = channel.dst_chain().id();
            debug!(chain_id = %dst_chain_id, port_id = %port_id, ctx = ?ctx, "resolving channel version by retrieving destination chain app version");

            // Note the compatibility logic below:
            // The destination chain may or may not implement `QueryAppVersionRequest`,
            // which is only available from ibc-go v2.0.0 or newer versions.
            // We detect if it is implemented by calling `is_unimplemented_port_query`.
            // If unimplemented, we can recover by simply using the default version.
            // This ensures compatibility with ibc-go v2.0.0+ and pre-v2.0.0.
            match dst_app_version(channel) {
                Ok(v) => Ok(v),
                Err(e) => {
                    if let ErrorDetail::GrpcStatus(s) = e.detail() {
                        if s.is_unimplemented_port_query() {
                            // Ensure compatibility & recover from the error,
                            // by using the default version.
                            debug!(chain_id = %dst_chain_id, "resorting to default version because destination chain does not expose app version gRPC endpoint");
                            return default_by_port(port_id);
                        }
                    }
                    // Propagate the error, this is not a recoverable problem.
                    Err(e).map_err(|e| ChannelError::query_app_version(channel.dst_chain().id(), e))
                }
            }
        }
    }
}
/// Resolves the [`Version`] to use during a channel
/// open handshake.
///
/// The channel version depends on the exact channel
/// handshake step [`ResolveContext`], as well as
/// on the current state of the channel.
Resolves the [`Version`] to use during a channel
open handshake.

The channel version depends on the exact channel
handshake step [`ResolveContext`], as well as
on the current state of the channel.
Resolves the [ ` Version ` ] to use during a channel open handshake . The channel version depends on the exact channel handshake step [ ` ResolveContext ` ] as well as on the current state of the channel .
pub fn resolve<ChainA: ChainHandle, ChainB: ChainHandle>(
    ctx: ResolveContext,
    channel: &Channel<ChainA, ChainB>,
) -> Result<Version, ChannelError> {
    let port_id = channel.dst_port_id();
    match ctx {
        ResolveContext::ChanOpenInit => {
            // When the channel is uninitialized, the relayer will use the
            // default channel version, depending on the port id.
            default_by_port(port_id)
        }
        ResolveContext::Other => {
            // Resolve the version by querying the application version on destination chain
            let dst_chain_id = channel.dst_chain().id();
            debug!(chain_id = %dst_chain_id, port_id = %port_id, ctx = ?ctx, "resolving channel version by retrieving destination chain app version");
            // Note the compatibility logic below:
            // The destination chain may or may not implement `QueryAppVersionRequest`,
            // which is only available from ibc-go v2.0.0 or newer versions.
            // We detect if it is implemented by calling `is_unimplemented_port_query`.
            // If unimplemented, we can recover by simply using the default version.
            // This ensures compatibility with ibc-go v2.0.0+ and pre-v2.0.0.
            match dst_app_version(channel) {
                Ok(v) => Ok(v),
                Err(e) => {
                    if let ErrorDetail::GrpcStatus(s) = e.detail() {
                        if s.is_unimplemented_port_query() {
                            // Ensure compatibility & recover from the error,
                            // by using the default version.
                            debug!(chain_id = %dst_chain_id, "resorting to default version because destination chain does not expose app version gRPC endpoint");
                            return default_by_port(port_id);
                        }
                    }
                    // Propagate the error, this is not a recoverable problem.
                    Err(e).map_err(|e| ChannelError::query_app_version(channel.dst_chain().id(), e))
                }
            }
        }
    }
}
pub fn resolve < ChainA : ChainHandle , ChainB : ChainHandle > ( ctx : ResolveContext , channel : & Channel < ChainA , ChainB > , ) -> Result < Version , ChannelError > { let port_id = channel . dst_port_id ( ) ; match ctx { ResolveContext :: ChanOpenInit => { // When the channel is uninitialized, the relayer will use the // default channel version, depending on the port id. default_by_port ( port_id ) } ResolveContext :: Other => { // Resolve the version by querying the application version on destination chain let dst_chain_id = channel . dst_chain ( ) . id ( ) ; debug ! ( chain_id dst_chain_id port_id port_id ctx ctx " " ) ; // Note the compatibility logic below: // The destination chain may or may not implement `QueryAppVersionRequest`, // which is only available from ibc-go v2.0.0 or newer versions. // We detect if it is implemented by calling `is_unimplemented_port_query`. // If unimplemented, we can recover by simply using the default version. // This ensures compatibility with ibc-go v2.0.0+ and pre-v2.0.0. match dst_app_version ( channel ) { Ok ( v ) => Ok ( v ) , Err ( e ) => { if let ErrorDetail :: GrpcStatus ( s ) = e . detail ( ) { if s . is_unimplemented_port_query ( ) { // Ensure compatibility & recover from the error, // by using the default version. debug ! ( chain_id dst_chain_id " " ) ; return default_by_port ( port_id ) ; } } // Propagate the error, this is not a recoverable problem. Err ( e ) . map_err ( | e | ChannelError :: query_app_version ( channel . dst_chain ( ) . id ( ) , e ) ) } } } } }
Resolves the [`Version`] to use during a channel
open handshake.
Resolves the [ ` Version ` ] to use during a channel open handshake .
ctx
ResolveContext
channel
&Channel<ChainA, ChainB>
ctx
ResolveContext
channel
&Channel<ChainA, ChainB>