From d280dfcffe721b8757a6a09d0a9a36c6a75db388 Mon Sep 17 00:00:00 2001 From: Pengfei Date: Mon, 30 Aug 2021 20:12:46 +0800 Subject: [PATCH] Added some features to SeedDB --- src/core/db/seed_db.cpp | 6 +++++- src/core/db/seed_db.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/db/seed_db.cpp b/src/core/db/seed_db.cpp index 3991314..61e484f 100644 --- a/src/core/db/seed_db.cpp +++ b/src/core/db/seed_db.cpp @@ -45,7 +45,7 @@ bool SeedDB::AddFromFile(const std::string& path) { return true; } -bool SeedDB::Save(const std::string& path) { +bool SeedDB::Save(const std::string& path) const { if (!FileUtil::CreateFullPath(path)) { LOG_ERROR(Service_FS, "Failed to create seed database"); return false; @@ -81,4 +81,8 @@ bool SeedDB::Save(const std::string& path) { return true; } +std::size_t SeedDB::GetSize() const { + return sizeof(u32) + SEEDDB_PADDING_BYTES + seeds.size() * SEEDDB_ENTRY_SIZE; +} + } // namespace Core diff --git a/src/core/db/seed_db.h b/src/core/db/seed_db.h index c694eb2..d411cb0 100644 --- a/src/core/db/seed_db.h +++ b/src/core/db/seed_db.h @@ -12,12 +12,14 @@ namespace Core { constexpr std::size_t SEEDDB_PADDING_BYTES{12}; constexpr std::size_t SEEDDB_ENTRY_PADDING_BYTES{8}; +constexpr std::size_t SEEDDB_ENTRY_SIZE{32}; using Seed = std::array; class SeedDB { public: bool AddFromFile(const std::string& path); - bool Save(const std::string& path); + bool Save(const std::string& path) const; + std::size_t GetSize() const; std::unordered_map seeds; };