mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
refactor: prepare mempool_persist for obfuscation key change
This commit is contained in:
parent
8e6e0acd36
commit
e50732d25f
1 changed files with 11 additions and 5 deletions
|
@ -58,15 +58,18 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
|||
try {
|
||||
uint64_t version;
|
||||
file >> version;
|
||||
std::vector<std::byte> xor_key;
|
||||
|
||||
if (version == MEMPOOL_DUMP_VERSION_NO_XOR_KEY) {
|
||||
// Leave XOR-key empty
|
||||
std::vector<std::byte> xor_key;
|
||||
file.SetXor(xor_key);
|
||||
} else if (version == MEMPOOL_DUMP_VERSION) {
|
||||
std::vector<std::byte> xor_key;
|
||||
file >> xor_key;
|
||||
file.SetXor(xor_key);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
file.SetXor(xor_key);
|
||||
|
||||
uint64_t total_txns_to_load;
|
||||
file >> total_txns_to_load;
|
||||
uint64_t txns_tried = 0;
|
||||
|
@ -177,12 +180,15 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
|
|||
const uint64_t version{pool.m_opts.persist_v1_dat ? MEMPOOL_DUMP_VERSION_NO_XOR_KEY : MEMPOOL_DUMP_VERSION};
|
||||
file << version;
|
||||
|
||||
std::vector<std::byte> xor_key(8);
|
||||
if (!pool.m_opts.persist_v1_dat) {
|
||||
std::vector<std::byte> xor_key(8);
|
||||
FastRandomContext{}.fillrand(xor_key);
|
||||
file << xor_key;
|
||||
file.SetXor(xor_key);
|
||||
} else {
|
||||
std::vector<std::byte> xor_key(8);
|
||||
file.SetXor(xor_key);
|
||||
}
|
||||
file.SetXor(xor_key);
|
||||
|
||||
uint64_t mempool_transactions_to_write(vinfo.size());
|
||||
file << mempool_transactions_to_write;
|
||||
|
|
Loading…
Add table
Reference in a new issue