refactor: encapsulate vector/array keys into Obfuscation

This commit is contained in:
Lőrinc
2025-07-05 14:39:19 +02:00
parent 377aab8e5a
commit 478d40afc6
13 changed files with 136 additions and 85 deletions

View File

@@ -1174,7 +1174,7 @@ static auto InitBlocksdirXorKey(const BlockManager::Options& opts)
};
}
LogInfo("Using obfuscation key for blocksdir *.dat files (%s): '%s'\n", fs::PathToString(opts.blocks_dir), HexStr(obfuscation));
return std::vector<std::byte>{obfuscation.begin(), obfuscation.end()};
return Obfuscation{obfuscation};
}
BlockManager::BlockManager(const util::SignalInterrupt& interrupt, Options opts)

View File

@@ -235,7 +235,7 @@ private:
const bool m_prune_mode;
const std::vector<std::byte> m_obfuscation;
const Obfuscation m_obfuscation;
/** Dirty block index entries. */
std::set<CBlockIndex*> m_dirty_blockindex;

View File

@@ -64,7 +64,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
if (version == MEMPOOL_DUMP_VERSION_NO_XOR_KEY) {
file.SetObfuscation({});
} else if (version == MEMPOOL_DUMP_VERSION) {
std::vector<std::byte> obfuscation(Obfuscation::KEY_SIZE);
Obfuscation obfuscation;
file >> obfuscation;
file.SetObfuscation(obfuscation);
} else {
@@ -183,8 +183,7 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
file << version;
if (!pool.m_opts.persist_v1_dat) {
std::vector<std::byte> obfuscation(Obfuscation::KEY_SIZE);
FastRandomContext{}.fillrand(obfuscation);
const Obfuscation obfuscation{FastRandomContext{}.randbytes<Obfuscation::KEY_SIZE>()};
file << obfuscation;
file.SetObfuscation(obfuscation);
} else {