mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
refactor: encapsulate vector/array keys into Obfuscation
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user