Skip to content

Commit

Permalink
Only recalculate the queue if it is empty (#6798)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Nov 12, 2024
1 parent 779231f commit 47b1010
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ pub fn start_job() {

fn populate_canisters() {
mutate_state(|state| {
state.data.cycles_balance_check_queue = VecDeque::from_iter(
state
.data
.local_communities
.iter()
.map(|(c, _)| CanisterId::from(*c))
.chain(state.data.local_groups.iter().map(|(g, _)| CanisterId::from(*g))),
);
if state.data.cycles_balance_check_queue.is_empty() {
state.data.cycles_balance_check_queue = VecDeque::from_iter(
state
.data
.local_communities
.iter()
.map(|(c, _)| CanisterId::from(*c))
.chain(state.data.local_groups.iter().map(|(g, _)| CanisterId::from(*g))),
);
}
});

if let Some(timer_id) = TIMER_ID.take() {
ic_cdk_timers::clear_timer(timer_id);
}
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/local_group_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct Data {
pub event_deduper: EventDeduper,
pub rng_seed: [u8; 32],
pub canisters_pending_events_migration_to_stable_memory: Vec<CanisterId>,
#[serde(default)]
pub cycles_balance_check_queue: VecDeque<CanisterId>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ pub fn start_job() {

fn populate_canisters() {
mutate_state(|state| {
state.data.cycles_balance_check_queue = VecDeque::from_iter(state.data.local_users.iter().map(|(u, _)| *u))
if state.data.cycles_balance_check_queue.is_empty() {
state.data.cycles_balance_check_queue = VecDeque::from_iter(state.data.local_users.iter().map(|(u, _)| *u));
}
});

if let Some(timer_id) = TIMER_ID.take() {
ic_cdk_timers::clear_timer(timer_id);
}
Expand Down

0 comments on commit 47b1010

Please sign in to comment.