From bf19069c53501231a2f3ba59afa067913ec4d3b2 Mon Sep 17 00:00:00 2001 From: w0xlt Date: Mon, 26 Dec 2022 06:14:24 -0300 Subject: [PATCH 1/2] wallet: remove `mempool_sequence` from `transactionAddedToMempool` --- src/interfaces/chain.h | 2 +- src/node/interfaces.cpp | 4 ++-- src/wallet/test/wallet_tests.cpp | 4 ++-- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 7a3d88b18f5..a713371b98f 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -268,7 +268,7 @@ public: { public: virtual ~Notifications() {} - virtual void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) {} + virtual void transactionAddedToMempool(const CTransactionRef& tx) {} virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {} virtual void blockConnected(const BlockInfo& block) {} virtual void blockDisconnected(const BlockInfo& block) {} diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 7a15f3649b5..bc4e0ce110a 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -420,7 +420,7 @@ public: virtual ~NotificationsProxy() = default; void TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override { - m_notifications->transactionAddedToMempool(tx, mempool_sequence); + m_notifications->transactionAddedToMempool(tx); } void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override { @@ -779,7 +779,7 @@ public: if (!m_node.mempool) return; LOCK2(::cs_main, m_node.mempool->cs); for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) { - notifications.transactionAddedToMempool(entry.GetSharedTx(), 0 /* mempool_sequence */); + notifications.transactionAddedToMempool(entry.GetSharedTx()); } } bool hasAssumedValidChain() override diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 0f703b7d00b..1f4e97bea9b 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -946,7 +946,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_sync_tx_invalid_state_test, TestingSetup) mtx.vin.clear(); mtx.vin.push_back(CTxIn(tx_id_to_spend, 0)); - wallet.transactionAddedToMempool(MakeTransactionRef(mtx), 0); + wallet.transactionAddedToMempool(MakeTransactionRef(mtx)); const uint256& good_tx_id = mtx.GetHash(); { @@ -967,7 +967,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_sync_tx_invalid_state_test, TestingSetup) static_cast(wallet.GetDatabase()).m_pass = false; mtx.vin.clear(); mtx.vin.push_back(CTxIn(good_tx_id, 0)); - BOOST_CHECK_EXCEPTION(wallet.transactionAddedToMempool(MakeTransactionRef(mtx), 0), + BOOST_CHECK_EXCEPTION(wallet.transactionAddedToMempool(MakeTransactionRef(mtx)), std::runtime_error, HasReason("DB error adding transaction to wallet, write failed")); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2c0ce89929c..4bcef6996e7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1355,7 +1355,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const SyncTxState& sta MarkInputsDirty(ptx); } -void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) { +void CWallet::transactionAddedToMempool(const CTransactionRef& tx) { LOCK(cs_wallet); SyncTransaction(tx, TxStateInMempool{}); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 137320acdab..99b1501f8de 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -516,7 +516,7 @@ public: */ CWalletTx* AddToWallet(CTransactionRef tx, const TxState& state, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true, bool rescanning_old_block = false); bool LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - void transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override; + void transactionAddedToMempool(const CTransactionRef& tx) override; void blockConnected(const interfaces::BlockInfo& block) override; void blockDisconnected(const interfaces::BlockInfo& block) override; void updatedBlockTip() override; From 55696a0ac30bcfbd555f71cbc8eac23b725f7dcf Mon Sep 17 00:00:00 2001 From: w0xlt Date: Mon, 26 Dec 2022 06:17:05 -0300 Subject: [PATCH 2/2] wallet: remove `mempool_sequence` from `transactionRemovedFromMempool` --- src/interfaces/chain.h | 2 +- src/node/interfaces.cpp | 2 +- src/wallet/wallet.cpp | 4 ++-- src/wallet/wallet.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index a713371b98f..9864e2075f0 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -269,7 +269,7 @@ public: public: virtual ~Notifications() {} virtual void transactionAddedToMempool(const CTransactionRef& tx) {} - virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {} + virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {} virtual void blockConnected(const BlockInfo& block) {} virtual void blockDisconnected(const BlockInfo& block) {} virtual void updatedBlockTip() {} diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index bc4e0ce110a..a693c8054c7 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -424,7 +424,7 @@ public: } void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override { - m_notifications->transactionRemovedFromMempool(tx, reason, mempool_sequence); + m_notifications->transactionRemovedFromMempool(tx, reason); } void BlockConnected(const std::shared_ptr& block, const CBlockIndex* index) override { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4bcef6996e7..d4718e82df4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1365,7 +1365,7 @@ void CWallet::transactionAddedToMempool(const CTransactionRef& tx) { } } -void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) { +void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) { LOCK(cs_wallet); auto it = mapWallet.find(tx->GetHash()); if (it != mapWallet.end()) { @@ -1411,7 +1411,7 @@ void CWallet::blockConnected(const interfaces::BlockInfo& block) m_last_block_processed = block.hash; for (size_t index = 0; index < block.data->vtx.size(); index++) { SyncTransaction(block.data->vtx[index], TxStateConfirmed{block.hash, block.height, static_cast(index)}); - transactionRemovedFromMempool(block.data->vtx[index], MemPoolRemovalReason::BLOCK, /*mempool_sequence=*/0); + transactionRemovedFromMempool(block.data->vtx[index], MemPoolRemovalReason::BLOCK); } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 99b1501f8de..fe3065b1b71 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -538,7 +538,7 @@ public: uint256 last_failed_block; }; ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional max_height, const WalletRescanReserver& reserver, bool fUpdate, const bool save_progress); - void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override; + void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) override; /** Set the next time this wallet should resend transactions to 12-36 hours from now, ~1 day on average. */ void SetNextResend() { m_next_resend = GetDefaultNextResend(); } /** Return true if all conditions for periodically resending transactions are met. */