Skip to content

Commit

Permalink
fix compat_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Sep 2, 2024
1 parent d55acfc commit 29b68f4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/relayer/src/chain/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub struct NamadaChain {
config: CosmosSdkConfig,
/// Namada context
ctx: NamadaImpl<HttpClient, wallet::NullWalletUtils, FsShieldedUtils, NullIo>,
compat_mode: CompatMode,
light_client: TmLightClient,
rt: Arc<TokioRuntime>,
keybase: KeyRing<NamadaKeyPair>,
Expand All @@ -110,17 +111,12 @@ impl NamadaChain {
}
);

let node_info = self
.rt
.block_on(fetch_node_info(self.ctx.client(), &self.config))?;
let compat_mode = CompatMode::from_version(node_info.version).unwrap_or(CompatMode::V0_37);

use crate::config::EventSourceMode as Mode;
let (event_source, monitor_tx) = match &self.config.event_source {
Mode::Push { url, batch_delay } => EventSource::websocket(
self.config.id.clone(),
url.clone(),
compat_mode,
self.compat_mode,
*batch_delay,
self.rt.clone(),
),
Expand Down Expand Up @@ -195,7 +191,12 @@ impl ChainEndpoint for NamadaChain {

let mut rpc_client = HttpClient::new(config.rpc_addr.clone())
.map_err(|e| Error::rpc(config.rpc_addr.clone(), e))?;
rpc_client.set_compat_mode(CompatMode::V0_37);
let node_info = rt.block_on(fetch_node_info(&rpc_client, &config))?;
let compat_mode = CompatMode::from_version(node_info.version)
.ok()
.or_else(|| config.compat_mode.clone().map(CompatMode::from))
.unwrap_or(CompatMode::V0_37);
rpc_client.set_compat_mode(compat_mode);

let node_info = rt.block_on(fetch_node_info(&rpc_client, &config))?;
let light_client = TmLightClient::from_cosmos_sdk_config(&config, node_info.id)?;
Expand Down Expand Up @@ -240,6 +241,7 @@ impl ChainEndpoint for NamadaChain {
Ok(Self {
config,
ctx,
compat_mode,
light_client,
rt,
keybase,
Expand Down

0 comments on commit 29b68f4

Please sign in to comment.