mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
wallet: batch and simplify ZapSelectTx process
The goal of the function is to erase the wallet transactions that match the inputted hashes. There is no need to traverse the database, reading record by record, to then perform single entry removals for each of them. To ensure consistency and improve performance, this change-set removes all tx records within a single atomic db batch operation, as well as it cleans up code, improves error handling and simplifies the transactions removal process entirely. This optimizes the removal of watch-only transactions during the wallet migration process and the 'removeprunedfunds' RPC command.
This commit is contained in:
@@ -918,8 +918,8 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
|
||||
BOOST_CHECK(wallet->HasWalletSpend(prev_tx));
|
||||
BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1u);
|
||||
|
||||
std::vector<uint256> vHashIn{ block_hash }, vHashOut;
|
||||
BOOST_CHECK_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK);
|
||||
std::vector<uint256> vHashIn{ block_hash };
|
||||
BOOST_CHECK(wallet->ZapSelectTx(vHashIn));
|
||||
|
||||
BOOST_CHECK(!wallet->HasWalletSpend(prev_tx));
|
||||
BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0u);
|
||||
|
||||
Reference in New Issue
Block a user