MCPcopy Create free account
hub / github.com/dfinity/orbit / run

Method run

core/station/impl/src/migration.rs:18–48  ·  view source on GitHub ↗

Run migrations for the station canister to ensure the stable memory schema is up-to-date. WARNING: This needs to be run before any other access to stable memory happens.

()

Source from the content-addressed store, hash-verified

16 ///
17 /// WARNING: This needs to be run before any other access to stable memory happens.
18 pub fn run() {
19 let mut system_info = read_system_info();
20 let stored_version = system_info.get_stable_memory_version();
21
22 if stored_version == STABLE_MEMORY_VERSION {
23 // Run the post-run checks that need to be run on every upgrade.
24 post_run();
25 return;
26 }
27
28 if stored_version > STABLE_MEMORY_VERSION {
29 trap(&format!(
30 "Cannot downgrade the station from memory layout version {stored_version} to {STABLE_MEMORY_VERSION}"
31 ));
32 }
33
34 if stored_version != STABLE_MEMORY_VERSION - 1 {
35 trap(&format!(
36 "Cannot skip upgrades between station memory layout version {stored_version} to {STABLE_MEMORY_VERSION}"
37 ));
38 }
39
40 apply_migration();
41
42 // Update the stable memory version to the latest version.
43 system_info.set_stable_memory_version(STABLE_MEMORY_VERSION);
44 write_system_info(system_info);
45
46 // Run the post-run checks that need to be run on every upgrade.
47 post_run();
48 }
49}
50
51/// If there is a check that needs to be run on every upgrade, regardless if the memory version has changed,

Callers

nothing calls this directly

Calls 7

read_system_infoFunction · 0.85
post_runFunction · 0.85
trapFunction · 0.85
apply_migrationFunction · 0.85
write_system_infoFunction · 0.85

Tested by

no test coverage detected