mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
wallet: provide WalletBatch to 'DeleteRecords'
So it can be used within an external db txn context.
This commit is contained in:
parent
122d103ca2
commit
055c0532fc
3 changed files with 11 additions and 6 deletions
|
@ -2036,9 +2036,15 @@ std::optional<MigrationData> LegacyDataSPKM::MigrateToDescriptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyDataSPKM::DeleteRecords()
|
bool LegacyDataSPKM::DeleteRecords()
|
||||||
|
{
|
||||||
|
return RunWithinTxn(m_storage.GetDatabase(), /*process_desc=*/"delete legacy records", [&](WalletBatch& batch){
|
||||||
|
return DeleteRecordsWithDB(batch);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LegacyDataSPKM::DeleteRecordsWithDB(WalletBatch& batch)
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
WalletBatch batch(m_storage.GetDatabase());
|
|
||||||
return batch.EraseRecords(DBKeys::LEGACY_TYPES);
|
return batch.EraseRecords(DBKeys::LEGACY_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,8 +366,9 @@ public:
|
||||||
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
||||||
* Does not modify this ScriptPubKeyMan. */
|
* Does not modify this ScriptPubKeyMan. */
|
||||||
std::optional<MigrationData> MigrateToDescriptor();
|
std::optional<MigrationData> MigrateToDescriptor();
|
||||||
/** Delete all the records ofthis LegacyScriptPubKeyMan from disk*/
|
/** Delete all the records of this LegacyScriptPubKeyMan from disk*/
|
||||||
bool DeleteRecords();
|
bool DeleteRecords();
|
||||||
|
bool DeleteRecordsWithDB(WalletBatch& batch);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implements the full legacy wallet behavior
|
// Implements the full legacy wallet behavior
|
||||||
|
|
|
@ -1335,10 +1335,8 @@ bool WalletBatch::WriteWalletFlags(const uint64_t flags)
|
||||||
|
|
||||||
bool WalletBatch::EraseRecords(const std::unordered_set<std::string>& types)
|
bool WalletBatch::EraseRecords(const std::unordered_set<std::string>& types)
|
||||||
{
|
{
|
||||||
return RunWithinTxn(*this, "erase records", [&types](WalletBatch& self) {
|
return std::all_of(types.begin(), types.end(), [&](const std::string& type) {
|
||||||
return std::all_of(types.begin(), types.end(), [&self](const std::string& type) {
|
return m_batch->ErasePrefix(DataStream() << type);
|
||||||
return self.m_batch->ErasePrefix(DataStream() << type);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue