Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homogenize ConnectionReader functions #349

Merged
merged 3 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased Changes

Special thanks to external contributors for this release: @CharlyCst ([#347]).

### FEATURES

- [changelog] Added "unreleased" section in `CHANGELOG.MD` to help streamline releases ([#274])
Expand All @@ -17,8 +19,10 @@
### IMPROVEMENTS

- [relayer-cli] Split tasks spawned by CLI commands into their own modules ([#331])
- [modules] Homogenize ConnectionReader trait so that all functions return owned objects ([#347])

[#331]: https://github.com/informalsystems/ibc-rs/pulls/331
[#347]: https://github.com/informalsystems/ibc-rs/issues/347

## v0.0.4
*October 19, 2020*
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::Height;
/// A context supplying all the necessary read-only dependencies for processing any `ConnectionMsg`.
pub trait ConnectionReader {
/// Returns the ConnectionEnd for the given identifier `conn_id`.
fn connection_end(&self, conn_id: &ConnectionId) -> Option<&ConnectionEnd>;
fn connection_end(&self, conn_id: &ConnectionId) -> Option<ConnectionEnd>;

/// Returns the ClientState for the given identifier `client_id`.
fn client_state(&self, client_id: &ClientId) -> Option<AnyClientState>;
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/handler/conn_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) fn process(
|| old_conn_end.counterparty().connection_id() == msg.counterparty_connection_id();

if state_is_consistent && counterparty_matches {
Ok(old_conn_end.clone())
Ok(old_conn_end)
} else {
// Old connection end is in incorrect state, propagate the error.
Err(Into::<Error>::into(Kind::ConnectionMismatch(
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/handler/conn_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn process(
msg.connection_id().clone(),
)))
} else {
Ok(old_conn_end.clone())
Ok(old_conn_end)
}
}
None => {
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/handler/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) fn process(
&& old_conn_end.client_id_matches(msg.client_id())
{
// A ConnectionEnd already exists and all validation passed.
Ok(old_conn_end.clone())
Ok(old_conn_end)
} else {
// A ConnectionEnd already exists and validation failed.
Err(Into::<Error>::into(
Expand Down
4 changes: 2 additions & 2 deletions modules/src/mock_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ impl MockContext {
impl ICS26Context for MockContext {}

impl ConnectionReader for MockContext {
fn connection_end(&self, cid: &ConnectionId) -> Option<&ConnectionEnd> {
self.connections.get(cid)
fn connection_end(&self, cid: &ConnectionId) -> Option<ConnectionEnd> {
self.connections.get(cid).cloned()
}

fn client_state(&self, client_id: &ClientId) -> Option<AnyClientState> {
Expand Down