ic_memory/runtime/
diagnostics.rs1use super::{MemoryRuntime, RuntimeDiagnosticError};
2use crate::{DiagnosticExport, RecoveredLedger, physical::CommitSnapshotDiagnostic};
3use ic_platform::stable_structures::Memory;
4
5impl<M: Memory> MemoryRuntime<M> {
6 pub fn diagnostic_export(&self) -> Result<DiagnosticExport, RuntimeDiagnosticError> {
8 if !self.is_bootstrapped() {
9 return Err(RuntimeDiagnosticError::NotBootstrapped);
10 }
11 self.growth
12 .verify()
13 .map_err(super::RuntimeConstructionError::from)?;
14 let recovered = self.ledger_record_from_memory()?.recover()?;
15 Ok(self.recovered_diagnostic_export(recovered))
16 }
17
18 pub fn commit_recovery_diagnostic(
23 &self,
24 ) -> Result<CommitSnapshotDiagnostic, RuntimeDiagnosticError> {
25 self.growth
26 .verify()
27 .map_err(super::RuntimeConstructionError::from)?;
28 let record = self.ledger_record_from_memory()?;
29 Ok(record.diagnostic())
30 }
31
32 fn recovered_diagnostic_export(&self, recovered: RecoveredLedger) -> DiagnosticExport {
33 DiagnosticExport::from_owned_ledger(recovered.into_ledger())
34 .with_memory_sizes(|record| self.memory_size_pages(record.slot().id()))
35 }
36}