Skip to content

Commit

Permalink
Remove some code duplication (#2970)
Browse files Browse the repository at this point in the history
## Motivation

`owned_chain_ids` and `own_chain_ids` do the same thing

## Proposal

Keep `owned_chain_ids`, as that name seems better

## Test Plan

CI

## Release Plan

- Nothing to do / These changes follow the usual release cycle.
  • Loading branch information
ndr-ds authored Nov 26, 2024
1 parent 7faf3f8 commit 3d05b4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 2 additions & 2 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ where
W: Persist<Target = Wallet>,
{
pub async fn process_inboxes_and_force_validator_updates(&mut self) {
for chain_id in self.wallet.own_chain_ids() {
for chain_id in self.wallet.owned_chain_ids() {
let chain_client = self
.make_chain_client(chain_id)
.expect("chains in the wallet must exist");
Expand All @@ -592,7 +592,7 @@ where
balance: Amount,
) -> Result<HashMap<ChainId, KeyPair>, Error> {
let mut key_pairs = HashMap::new();
for chain_id in self.wallet.own_chain_ids() {
for chain_id in self.wallet.owned_chain_ids() {
if key_pairs.len() == num_chains {
break;
}
Expand Down
9 changes: 1 addition & 8 deletions linera-client/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,8 @@ impl Wallet {
self.chains.keys().copied().collect()
}

pub fn owned_chain_ids(&self) -> Vec<ChainId> {
self.chains
.iter()
.filter_map(|(chain_id, chain)| chain.key_pair.is_some().then_some(*chain_id))
.collect()
}

/// Returns the list of all chain IDs for which we have a secret key.
pub fn own_chain_ids(&self) -> Vec<ChainId> {
pub fn owned_chain_ids(&self) -> Vec<ChainId> {
self.chains
.iter()
.filter_map(|(chain_id, chain)| chain.key_pair.is_some().then_some(*chain_id))
Expand Down

0 comments on commit 3d05b4d

Please sign in to comment.