Skip to content

Commit

Permalink
informalsystems#1024 Optimize clients sorting by client_id_suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
blewater committed Oct 6, 2021
1 parent 82dd5b6 commit 6f68b2a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,9 @@ impl ChainEndpoint for CosmosSdkChain {
.collect();

// Sort by client identifier counter
clients.sort_by(|a, b| {
client_id_suffix(&a.client_id)
.unwrap_or(0) // Fallback to `0` suffix (no sorting) if client id is malformed
.cmp(&client_id_suffix(&b.client_id).unwrap_or(0))
});
clients.sort_by_cached_key(|c|
client_id_suffix(&c.client_id)
.unwrap_or(0));

Ok(clients)
}
Expand Down

0 comments on commit 6f68b2a

Please sign in to comment.