mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-11 07:09:29 +02:00
Minimize mempool lock, sync txo spender index only when and if needed
We sync txospenderindex after we've checked the mempool for spending transaction, and only if search is not limited to the mempool and no spending transactions have been found for some of the provided outpoints. This should minimize the chance of having a block containing a spending transaction that is no longer in the mempool but has not been indexed yet.
This commit is contained in:
@@ -116,6 +116,10 @@ class GetTxSpendingPrevoutTest(BitcoinTestFramework):
|
||||
result = self.nodes[2].gettxspendingprevout([{ 'txid' : confirmed_utxo['txid'], 'vout' : 0}, {'txid' : txidA, 'vout' : 1} ], return_spending_tx=True)
|
||||
assert_equal(result, [ {'txid' : confirmed_utxo['txid'], 'vout' : 0}, {'txid' : txidA, 'vout' : 1}])
|
||||
|
||||
# spending transaction is not found if we only search the mempool
|
||||
result = self.nodes[0].gettxspendingprevout([ {'txid' : confirmed_utxo['txid'], 'vout' : 0}, {'txid' : txidA, 'vout' : 1} ], return_spending_tx=True, mempool_only=True)
|
||||
assert_equal(result, [ {'txid' : confirmed_utxo['txid'], 'vout' : 0}, {'txid' : txidA, 'vout' : 1}])
|
||||
|
||||
self.log.info("Check that our txospenderindex is updated when a reorg replaces a spending transaction")
|
||||
confirmed_utxo = self.wallet.get_utxo(mark_as_spent = False)
|
||||
tx1 = create_tx(utxos_to_spend=[confirmed_utxo], num_outputs=1)
|
||||
|
||||
Reference in New Issue
Block a user