Skip to content

Commit

Permalink
Handle edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
max-dfinity committed Dec 19, 2024
1 parent de3c7c2 commit c8b83d2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6988,19 +6988,30 @@ impl Governance {
// This is different from what we do in most places because we usually rely
// on trapping to retain the lock, but we can't do that here since we're not
// working on a single neuron.
self.with_neuron_mut(&neuron_id, |neuron| {
neuron.maturity_e8s_equivalent = neuron_stake;
neuron.cached_neuron_stake_e8s = 0;
neuron.spawn_at_timestamp_seconds =
original_spawn_at_timestamp_seconds;
});
println!(
"{}Error spawning neuron: {:?}. Ledger update failed with err: {:?}. \
Reverted state, so another attempt can be made.",
Reverting state, so another attempt can be made.",
LOG_PREFIX,
neuron_id,
error,
);
);
match self.with_neuron_mut(&neuron_id, |neuron| {
neuron.maturity_e8s_equivalent = neuron_stake;
neuron.cached_neuron_stake_e8s = 0;
neuron.spawn_at_timestamp_seconds =
original_spawn_at_timestamp_seconds;
}) {
Ok() => (),
Err(e) => {
println!(
"{} Error reverting state for neuron: {:?}. Retaining lock: {}"
LOG_PREFIX,
neuron_id,
e
);
lock.retain();
}
};
}
};
}
Expand Down

0 comments on commit c8b83d2

Please sign in to comment.