Manages ROM versioning, snapshots, and rollback capabilities. More...
#include <rom_version_manager.h>
Classes | |
struct | Config |
struct | Stats |
Public Member Functions | |
RomVersionManager (Rom *rom) | |
~RomVersionManager () | |
absl::Status | Initialize (const Config &config) |
absl::StatusOr< std::string > | CreateSnapshot (const std::string &description, const std::string &creator, bool is_checkpoint=false) |
absl::Status | RestoreSnapshot (const std::string &snapshot_id) |
absl::Status | MarkAsSafePoint (const std::string &snapshot_id) |
std::vector< RomSnapshot > | GetSnapshots (bool safe_points_only=false) const |
absl::StatusOr< RomSnapshot > | GetSnapshot (const std::string &snapshot_id) const |
absl::Status | DeleteSnapshot (const std::string &snapshot_id) |
absl::StatusOr< VersionDiff > | GenerateDiff (const std::string &from_id, const std::string &to_id) const |
absl::StatusOr< bool > | DetectCorruption () |
absl::Status | AutoRecover () |
absl::Status | ExportSnapshot (const std::string &snapshot_id, const std::string &filepath) |
absl::Status | ImportSnapshot (const std::string &filepath) |
std::string | GetCurrentHash () const |
absl::Status | CleanupOldSnapshots () |
Stats | GetStats () const |
Private Member Functions | |
std::string | ComputeRomHash () const |
std::vector< uint8_t > | CompressData (const std::vector< uint8_t > &data) const |
std::vector< uint8_t > | DecompressData (const std::vector< uint8_t > &compressed) const |
absl::Status | ValidateRomIntegrity () const |
size_t | GetTotalStorageUsed () const |
void | PruneOldSnapshots () |
Private Attributes | |
Rom * | rom_ |
Config | config_ |
std::map< std::string, RomSnapshot > | snapshots_ |
std::string | last_known_hash_ |
int64_t | last_backup_time_ |
Manages ROM versioning, snapshots, and rollback capabilities.
Provides:
Definition at line 66 of file rom_version_manager.h.
|
explicit |
Definition at line 51 of file rom_version_manager.cc.
yaze::net::RomVersionManager::~RomVersionManager | ( | ) |
Definition at line 56 of file rom_version_manager.cc.
absl::Status yaze::net::RomVersionManager::Initialize | ( | const Config & | config | ) |
Initialize version management
Definition at line 60 of file rom_version_manager.cc.
References config_, CreateSnapshot(), and MarkAsSafePoint().
absl::StatusOr< std::string > yaze::net::RomVersionManager::CreateSnapshot | ( | const std::string & | description, |
const std::string & | creator, | ||
bool | is_checkpoint = false |
||
) |
Create a snapshot of current ROM state
Definition at line 77 of file rom_version_manager.cc.
References CleanupOldSnapshots(), yaze::net::RomVersionManager::Config::compress_snapshots, CompressData(), yaze::net::RomSnapshot::compressed_size, config_, yaze::net::RomSnapshot::creator, yaze::Rom::data(), yaze::net::RomSnapshot::description, yaze::net::RomSnapshot::is_checkpoint, yaze::Rom::is_loaded(), yaze::net::RomSnapshot::is_safe_point, last_known_hash_, yaze::net::RomVersionManager::Config::max_snapshots, rom_, yaze::net::RomSnapshot::rom_data, yaze::net::RomSnapshot::rom_hash, yaze::Rom::size(), yaze::net::RomSnapshot::snapshot_id, snapshots_, and yaze::net::RomSnapshot::timestamp.
Referenced by yaze::net::CollaborationService::ApplyApprovedProposal(), yaze::net::CollaborationService::ApplyRomSync(), yaze::net::CollaborationService::HostSession(), Initialize(), yaze::net::CollaborationService::JoinSession(), yaze::gui::CollaborationPanel::RenderVersionHistoryTab(), RestoreSnapshot(), and yaze::net::ProposalApprovalManager::SubmitProposal().
absl::Status yaze::net::RomVersionManager::RestoreSnapshot | ( | const std::string & | snapshot_id | ) |
Restore ROM to a previous snapshot
Definition at line 127 of file rom_version_manager.cc.
References yaze::net::RomVersionManager::Config::compress_snapshots, config_, CreateSnapshot(), DecompressData(), yaze::Rom::is_loaded(), last_known_hash_, yaze::Rom::mutable_data(), rom_, yaze::net::RomSnapshot::rom_data, yaze::net::RomSnapshot::rom_hash, yaze::Rom::size(), and snapshots_.
Referenced by yaze::net::CollaborationService::ApplyRomSync(), AutoRecover(), yaze::gui::CollaborationPanel::RenderApprovalProposal(), and yaze::gui::CollaborationPanel::RenderVersionSnapshot().
absl::Status yaze::net::RomVersionManager::MarkAsSafePoint | ( | const std::string & | snapshot_id | ) |
Mark a snapshot as a safe point (host-verified)
Definition at line 170 of file rom_version_manager.cc.
References snapshots_.
Referenced by yaze::net::CollaborationService::HostSession(), Initialize(), yaze::net::CollaborationService::JoinSession(), and yaze::gui::CollaborationPanel::RenderVersionSnapshot().
std::vector< RomSnapshot > yaze::net::RomVersionManager::GetSnapshots | ( | bool | safe_points_only = false | ) | const |
Get all snapshots, sorted by timestamp
Definition at line 180 of file rom_version_manager.cc.
References snapshots_.
Referenced by yaze::net::CollaborationService::ApplyRomSync(), AutoRecover(), and yaze::gui::CollaborationPanel::RenderVersionHistoryTab().
absl::StatusOr< RomSnapshot > yaze::net::RomVersionManager::GetSnapshot | ( | const std::string & | snapshot_id | ) | const |
Get a specific snapshot
Definition at line 198 of file rom_version_manager.cc.
References snapshots_.
absl::Status yaze::net::RomVersionManager::DeleteSnapshot | ( | const std::string & | snapshot_id | ) |
Delete a snapshot
Definition at line 207 of file rom_version_manager.cc.
References snapshots_.
Referenced by yaze::gui::CollaborationPanel::RenderVersionSnapshot().
absl::StatusOr< VersionDiff > yaze::net::RomVersionManager::GenerateDiff | ( | const std::string & | from_id, |
const std::string & | to_id | ||
) | const |
Generate diff between two snapshots
absl::StatusOr< bool > yaze::net::RomVersionManager::DetectCorruption | ( | ) |
Check for ROM corruption
Definition at line 222 of file rom_version_manager.cc.
References config_, yaze::Rom::data(), yaze::net::RomVersionManager::Config::enable_corruption_detection, yaze::Rom::is_loaded(), last_known_hash_, rom_, yaze::Rom::size(), and ValidateRomIntegrity().
Referenced by yaze::gui::CollaborationPanel::RenderVersionHistoryTab().
absl::Status yaze::net::RomVersionManager::AutoRecover | ( | ) |
Auto-recover from corruption using nearest safe point
Definition at line 252 of file rom_version_manager.cc.
References GetSnapshots(), and RestoreSnapshot().
absl::Status yaze::net::RomVersionManager::ExportSnapshot | ( | const std::string & | snapshot_id, |
const std::string & | filepath | ||
) |
Export snapshot to file
absl::Status yaze::net::RomVersionManager::ImportSnapshot | ( | const std::string & | filepath | ) |
Import snapshot from file
std::string yaze::net::RomVersionManager::GetCurrentHash | ( | ) | const |
Get current ROM hash
Definition at line 263 of file rom_version_manager.cc.
References yaze::Rom::data(), yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().
Referenced by yaze::net::CollaborationService::HostSession(), yaze::net::CollaborationService::Initialize(), yaze::net::CollaborationService::JoinSession(), yaze::gui::CollaborationPanel::RenderVersionHistoryTab(), and yaze::net::CollaborationService::SubmitChangesAsProposal().
absl::Status yaze::net::RomVersionManager::CleanupOldSnapshots | ( | ) |
Cleanup old snapshots based on policy
Definition at line 273 of file rom_version_manager.cc.
References config_, GetTotalStorageUsed(), yaze::net::RomVersionManager::Config::max_snapshots, yaze::net::RomVersionManager::Config::max_storage_mb, and snapshots_.
Referenced by CreateSnapshot().
RomVersionManager::Stats yaze::net::RomVersionManager::GetStats | ( | ) | const |
Definition at line 303 of file rom_version_manager.cc.
References yaze::net::RomVersionManager::Stats::auto_backups, yaze::net::RomVersionManager::Stats::manual_checkpoints, yaze::net::RomVersionManager::Stats::newest_snapshot_timestamp, yaze::net::RomVersionManager::Stats::oldest_snapshot_timestamp, yaze::net::RomVersionManager::Stats::safe_points, snapshots_, yaze::net::RomVersionManager::Stats::total_snapshots, and yaze::net::RomVersionManager::Stats::total_storage_bytes.
Referenced by yaze::gui::CollaborationPanel::RenderVersionHistoryTab().
|
private |
Definition at line 328 of file rom_version_manager.cc.
References yaze::Rom::data(), yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().
|
private |
Definition at line 338 of file rom_version_manager.cc.
Referenced by CreateSnapshot().
|
private |
Definition at line 345 of file rom_version_manager.cc.
Referenced by RestoreSnapshot().
|
private |
Definition at line 351 of file rom_version_manager.cc.
References yaze::Rom::is_loaded(), rom_, and yaze::Rom::size().
Referenced by DetectCorruption().
|
private |
Definition at line 370 of file rom_version_manager.cc.
References snapshots_.
Referenced by CleanupOldSnapshots().
|
private |
|
private |
Definition at line 172 of file rom_version_manager.h.
Referenced by ComputeRomHash(), CreateSnapshot(), DetectCorruption(), GetCurrentHash(), RestoreSnapshot(), and ValidateRomIntegrity().
|
private |
Definition at line 173 of file rom_version_manager.h.
Referenced by CleanupOldSnapshots(), CreateSnapshot(), DetectCorruption(), Initialize(), and RestoreSnapshot().
|
private |
Definition at line 174 of file rom_version_manager.h.
Referenced by CleanupOldSnapshots(), CreateSnapshot(), DeleteSnapshot(), GetSnapshot(), GetSnapshots(), GetStats(), GetTotalStorageUsed(), MarkAsSafePoint(), and RestoreSnapshot().
|
private |
Definition at line 175 of file rom_version_manager.h.
Referenced by CreateSnapshot(), DetectCorruption(), and RestoreSnapshot().
|
private |
Definition at line 176 of file rom_version_manager.h.