Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 1,026 Lines • ▼ Show 20 Lines | DBErrors WalletBatch::ZapSelectTx(std::vector<TxId> &txIdsIn, | ||||
} | } | ||||
if (delerror) { | if (delerror) { | ||||
return DBErrors::CORRUPT; | return DBErrors::CORRUPT; | ||||
} | } | ||||
return DBErrors::LOAD_OK; | return DBErrors::LOAD_OK; | ||||
} | } | ||||
DBErrors WalletBatch::ZapWalletTx(std::list<CWalletTx> &vWtx) { | |||||
// Build list of wallet TXs. | |||||
std::vector<TxId> txIds; | |||||
DBErrors err = FindWalletTx(txIds, vWtx); | |||||
if (err != DBErrors::LOAD_OK) { | |||||
return err; | |||||
} | |||||
// Erase each wallet TX. | |||||
for (const TxId &txid : txIds) { | |||||
if (!EraseTx(txid)) { | |||||
return DBErrors::CORRUPT; | |||||
} | |||||
} | |||||
return DBErrors::LOAD_OK; | |||||
} | |||||
void MaybeCompactWalletDB() { | void MaybeCompactWalletDB() { | ||||
static std::atomic<bool> fOneThread; | static std::atomic<bool> fOneThread; | ||||
if (fOneThread.exchange(true)) { | if (fOneThread.exchange(true)) { | ||||
return; | return; | ||||
} | } | ||||
for (const std::shared_ptr<CWallet> &pwallet : GetWallets()) { | for (const std::shared_ptr<CWallet> &pwallet : GetWallets()) { | ||||
WalletDatabase &dbh = pwallet->GetDBHandle(); | WalletDatabase &dbh = pwallet->GetDBHandle(); | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |