Skip to content

Commit

Permalink
Clear the principal to userId map to ensure latest values are used
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Aug 2, 2024
1 parent 27215f3 commit 42ab619
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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::Data;
use crate::{mutate_state, Data};
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk::post_upgrade;
Expand All @@ -24,4 +24,7 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

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

// TODO remove this after upgrade
mutate_state(|state| state.data.principal_to_user_id_map.clear());
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ impl PrincipalToUserIdMap {
pub fn get(&self, principal: &Principal) -> Option<UserId> {
self.map.get(principal).map(|u| u.into())
}

pub fn clear(&mut self) {
self.map.clear_new()
}
}

fn init_map() -> StableBTreeMap<Principal, Principal, Memory> {
Expand Down

0 comments on commit 42ab619

Please sign in to comment.