Skip to content

Commit

Permalink
Avoid making c2c call in post_upgrade (#6121)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jul 26, 2024
1 parent d5c3657 commit 6b0c38f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions backend/canisters/user_index/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::{mutate_state, Data};
use crate::{jobs, mutate_state, Data};
use candid::Principal;
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
Expand Down Expand Up @@ -32,7 +32,7 @@ fn post_upgrade(args: Args) {
state.data.airdrop_bot_canister_id = Principal::from_text("6pwwx-laaaa-aaaaf-bmy6a-cai").unwrap();
}

state.push_event_to_all_local_user_indexes(
let events = [
local_user_index_canister::Event::UserRegistered(UserRegistered {
user_id: state.data.proposals_bot_canister_id.into(),
user_principal: state.data.proposals_bot_canister_id,
Expand All @@ -41,9 +41,6 @@ fn post_upgrade(args: Args) {
user_type: UserType::OcControlledBot,
referred_by: None,
}),
None,
);
state.push_event_to_all_local_user_indexes(
local_user_index_canister::Event::UserRegistered(UserRegistered {
user_id: state.data.airdrop_bot_canister_id.into(),
user_principal: state.data.airdrop_bot_canister_id,
Expand All @@ -52,8 +49,14 @@ fn post_upgrade(args: Args) {
user_type: UserType::OcControlledBot,
referred_by: None,
}),
None,
);
];

for canister_id in state.data.local_index_map.canisters() {
for event in events.iter() {
state.data.user_index_event_sync_queue.push(*canister_id, event.clone());
}
}
jobs::sync_events_to_local_user_index_canisters::start_job_if_required(state);
});

info!(version = %args.wasm_version, "Post-upgrade complete");
Expand Down

0 comments on commit 6b0c38f

Please sign in to comment.