Skip to content

Commit

Permalink
Remove has route (#740)
Browse files Browse the repository at this point in the history
* remove has route and refactor validate and execute functions

* add changelog
  • Loading branch information
PanGan21 authored Jul 5, 2023
1 parent 85fa44e commit ab69f3e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug/503-update-unclog-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove Router::has_route
([\#503](https://github.com/cosmos/ibc-rs/issues/503))
13 changes: 0 additions & 13 deletions crates/ibc/src/core/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use super::ics03_connection::handler::{
conn_open_ack, conn_open_confirm, conn_open_init, conn_open_try,
};
use super::ics03_connection::msgs::ConnectionMsg;
use super::ics04_channel::error::ChannelError;
use super::ics04_channel::handler::acknowledgement::{
acknowledgement_packet_execute, acknowledgement_packet_validate,
};
Expand Down Expand Up @@ -72,9 +71,6 @@ where
let module_id = ctx
.lookup_module_channel(&msg)
.map_err(ContextError::from)?;
if !ctx.has_route(&module_id) {
return Err(ChannelError::RouteNotFound).map_err(ContextError::from)?;
}

match msg {
ChannelMsg::OpenInit(msg) => chan_open_init_validate(ctx, module_id, msg),
Expand All @@ -88,9 +84,6 @@ where
}
MsgEnvelope::Packet(msg) => {
let module_id = ctx.lookup_module_packet(&msg).map_err(ContextError::from)?;
if !ctx.has_route(&module_id) {
return Err(ChannelError::RouteNotFound).map_err(ContextError::from)?;
}

match msg {
PacketMsg::Recv(msg) => recv_packet_validate(ctx, msg),
Expand Down Expand Up @@ -135,9 +128,6 @@ where
let module_id = ctx
.lookup_module_channel(&msg)
.map_err(ContextError::from)?;
if !ctx.has_route(&module_id) {
return Err(ChannelError::RouteNotFound).map_err(ContextError::from)?;
}

match msg {
ChannelMsg::OpenInit(msg) => chan_open_init_execute(ctx, module_id, msg),
Expand All @@ -151,9 +141,6 @@ where
}
MsgEnvelope::Packet(msg) => {
let module_id = ctx.lookup_module_packet(&msg).map_err(ContextError::from)?;
if !ctx.has_route(&module_id) {
return Err(ChannelError::RouteNotFound).map_err(ContextError::from)?;
}

match msg {
PacketMsg::Recv(msg) => recv_packet_execute(ctx, module_id, msg),
Expand Down
3 changes: 0 additions & 3 deletions crates/ibc/src/core/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ pub trait Router {
/// Returns a mutable reference to a `Module` registered against the specified `ModuleId`
fn get_route_mut(&mut self, module_id: &ModuleId) -> Option<&mut dyn Module>;

/// Returns true if the `Router` has a `Module` registered against the specified `ModuleId`
fn has_route(&self, module_id: &ModuleId) -> bool;

/// Return the module_id associated with a given port_id
fn lookup_module_by_port(&self, port_id: &PortId) -> Option<ModuleId>;

Expand Down
4 changes: 0 additions & 4 deletions crates/ibc/src/mock/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,6 @@ impl Router for MockContext {
}
}

fn has_route(&self, module_id: &ModuleId) -> bool {
self.router.get(module_id).is_some()
}

fn lookup_module_by_port(&self, port_id: &PortId) -> Option<ModuleId> {
self.ibc_store.lock().port_to_module.get(port_id).cloned()
}
Expand Down

0 comments on commit ab69f3e

Please sign in to comment.