diff --git a/rs/nns/governance/src/governance.rs b/rs/nns/governance/src/governance.rs index 0e85ed55a115..895cadd0e859 100644 --- a/rs/nns/governance/src/governance.rs +++ b/rs/nns/governance/src/governance.rs @@ -95,6 +95,7 @@ use ic_nns_constants::{ LIFELINE_CANISTER_ID, REGISTRY_CANISTER_ID, ROOT_CANISTER_ID, SNS_WASM_CANISTER_ID, SUBNET_RENTAL_CANISTER_ID, }; +use ic_nns_governance_api::pb::v1::list_neurons::NeuronSubaccount; use ic_nns_governance_api::{ pb::v1::{ self as api, @@ -2277,17 +2278,21 @@ impl Governance { BTreeSet::new() }; - let mut neurons_by_subaccount: BTreeSet = neuron_subaccounts - .unwrap_or_default() - .iter() - .flat_map(|neuron_subaccount| { - Self::bytes_to_subaccount(&neuron_subaccount.subaccount) - .ok() - .and_then(|subaccount| { - self.neuron_store.get_neuron_id_for_subaccount(subaccount) + let neurons_by_subaccount: BTreeSet = neuron_subaccounts + .as_ref() + .map(|subaccounts| { + subaccounts + .iter() + .flat_map(|neuron_subaccount| { + Self::bytes_to_subaccount(&neuron_subaccount.subaccount) + .ok() + .and_then(|subaccount| { + self.neuron_store.get_neuron_id_for_subaccount(subaccount) + }) }) + .collect() }) - .collect(); + .unwrap_or_default(); // Concatenate (explicit and implicit)-ly included neurons. let mut requested_neuron_ids: BTreeSet =