mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
wallet: filter for keys only before record deser in salvage
When salvaging a wallet, avoid deserializing any records that we don't care about, i.e. filter for keys only before the deserialization.
This commit is contained in:
parent
544e12a4e8
commit
0bbe26a1af
1 changed files with 7 additions and 2 deletions
|
@ -16,6 +16,11 @@ static const char *HEADER_END = "HEADER=END";
|
||||||
static const char *DATA_END = "DATA=END";
|
static const char *DATA_END = "DATA=END";
|
||||||
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
|
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
|
||||||
|
|
||||||
|
static bool KeyFilter(const std::string& type)
|
||||||
|
{
|
||||||
|
return WalletBatch::IsKeyType(type) || type == DBKeys::HDCHAIN;
|
||||||
|
}
|
||||||
|
|
||||||
bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
@ -129,9 +134,9 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
|
||||||
{
|
{
|
||||||
// Required in LoadKeyMetadata():
|
// Required in LoadKeyMetadata():
|
||||||
LOCK(dummyWallet.cs_wallet);
|
LOCK(dummyWallet.cs_wallet);
|
||||||
fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr);
|
fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr, KeyFilter);
|
||||||
}
|
}
|
||||||
if (!WalletBatch::IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
|
if (!KeyFilter(strType)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!fReadOK)
|
if (!fReadOK)
|
||||||
|
|
Loading…
Add table
Reference in a new issue