From 9ce72c990a7ceac2e18d81b9b496e1b819f686e6 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Thu, 11 Jan 2024 08:56:03 +0000 Subject: [PATCH] Refresh neurons after spawning or disbursing (#5160) --- backend/canisters/neuron_controller/CHANGELOG.md | 1 + .../neuron_controller/impl/src/jobs/process_neurons.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/backend/canisters/neuron_controller/CHANGELOG.md b/backend/canisters/neuron_controller/CHANGELOG.md index f7f9f1141a..4f292cbd93 100644 --- a/backend/canisters/neuron_controller/CHANGELOG.md +++ b/backend/canisters/neuron_controller/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Separate spawning neurons from active neurons ([#5159](https://github.com/open-chat-labs/open-chat/pull/5159)) +- Refresh neurons after spawning or disbursing ([#5160](https://github.com/open-chat-labs/open-chat/pull/5160)) ## [[2.0.1002](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1002-neuron_controller)] - 2024-01-10 diff --git a/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs b/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs index 948395a1c9..c15e6ec81b 100644 --- a/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs +++ b/backend/canisters/neuron_controller/impl/src/jobs/process_neurons.rs @@ -75,12 +75,20 @@ async fn run_async() { } }); + let mut neurons_updated = false; if !neurons_to_spawn.is_empty() { spawn_neurons(neurons_to_spawn).await; + neurons_updated = true; } if !neurons_to_disburse.is_empty() { disburse_neurons(neurons_to_disburse).await; + neurons_updated = true; + } + + if neurons_updated { + // Refresh the neurons again given that they've been updated + ic_cdk_timers::set_timer(Duration::ZERO, || ic_cdk::spawn(run_async())); } } }