I have a lookupMap
pub struct App {
update_user_ids: LookupMap<u128, u128>,
}
I want to reset the update_user_ids, how should I do that?
This below function does not work if I give key_prefix id "f657bf68" same as that used in initialization of update_user_ids in #[init] pub fn new().
pub fn reset (&mut self) {
self.update_user_ids = LookupMap::new(b"f657bf68".to_vec());
}
Well, by design, LookupMap
does not have a way to delete all its entries since it does not know the keys. You can only insert and delete entries by known keys. If you know the keys, you can call self.update_user_ids.remove()
in a loop. If your intention is to start from scratch, I recommend you recreate an account to wipe the state completely; otherwise, use UnorderedMap
or TreeMap
which have clear()
implementation.