-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "migrate individual template data stage 1 (#198)"
This reverts commit 951f0ab.
- Loading branch information
1 parent
951f0ab
commit 0ded555
Showing
8 changed files
with
13 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 9 additions & 14 deletions
23
src/canister/individual_user_template/src/api/canister_lifecycle/pre_upgrade.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
use ciborium::ser; | ||
use ic_stable_structures::writer::Writer; | ||
use shared_utils::common::utils::stable_memory_serializer_deserializer; | ||
|
||
use crate::data_model::memory; | ||
use crate::CANISTER_DATA; | ||
|
||
pub const BUFFER_SIZE_BYTES: usize = 2 * 1024 * 1024; // 2 MiB | ||
|
||
#[ic_cdk::pre_upgrade] | ||
fn pre_upgrade() { | ||
let mut state_bytes = vec![]; | ||
CANISTER_DATA.with(|canister_data_ref_cell| { | ||
ser::into_writer(&*canister_data_ref_cell.borrow(), &mut state_bytes) | ||
}) | ||
.expect("failed to encode state"); | ||
|
||
let len = state_bytes.len() as u32; | ||
let mut memory = memory::get_upgrades_memory(); | ||
let mut writer = Writer::new(&mut memory, 0); | ||
writer.write(&len.to_le_bytes()).unwrap(); | ||
writer.write(&state_bytes).unwrap(); | ||
} | ||
let canister_data = canister_data_ref_cell.take(); | ||
stable_memory_serializer_deserializer::serialize_to_stable_memory( | ||
canister_data, | ||
BUFFER_SIZE_BYTES, | ||
) | ||
.expect("Failed to serialize canister data"); | ||
}); | ||
} |
22 changes: 0 additions & 22 deletions
22
src/canister/individual_user_template/src/data_model/memory.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters