Merge bitcoin/bitcoin#26752: wallet: Remove mempool_sequence from interface methods

55696a0ac3 wallet: remove `mempool_sequence` from `transactionRemovedFromMempool` (w0xlt)
bf19069c53 wallet: remove `mempool_sequence` from `transactionAddedToMempool` (w0xlt)

Pull request description:

  This PR removes `mempool_sequence` from `transactionRemovedFromMempool` and `transactionAddedToMempool`.

  `mempool_sequence` is  not used in these methods, only in ZMQ notifications.

ACKs for top commit:
  instagibbs:
    ACK https://github.com/bitcoin/bitcoin/pull/26752/commits/55696a0ac30bcfbd555f71cbc8eac23b725f7dcf

Tree-SHA512: 621e89230bcb6edfed83e2758601a2b093822fc2dc4e9bfb00487e340f2bc4c5ac3bf6df3ca00b7fe55bb3df15858820f2bf698f403d2e48b915dd9eb47b63e0
This commit is contained in:
glozow committed 2023-01-04 17:53:58 +00:00
commit 65ecf24b5c
5 files changed
+12 -12

No files matched your search

+2 -2
View File
@@ -268,8 +268,8 @@ public:
{ {
public: public:
virtual ~Notifications() {} 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 transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {}
virtual void blockConnected(const BlockInfo& block) {} virtual void blockConnected(const BlockInfo& block) {}
virtual void blockDisconnected(const BlockInfo& block) {} virtual void blockDisconnected(const BlockInfo& block) {}
virtual void updatedBlockTip() {} virtual void updatedBlockTip() {}
+3 -3
View File
@@ -420,11 +420,11 @@ public:
virtual ~NotificationsProxy() = default; virtual ~NotificationsProxy() = default;
void TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) override 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 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<const CBlock>& block, const CBlockIndex* index) override void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{ {
@@ -776,7 +776,7 @@ public:
if (!m_node.mempool) return; if (!m_node.mempool) return;
LOCK2(::cs_main, m_node.mempool->cs); LOCK2(::cs_main, m_node.mempool->cs);
for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) { for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) {
notifications.transactionAddedToMempool(entry.GetSharedTx(), 0 /* mempool_sequence */); notifications.transactionAddedToMempool(entry.GetSharedTx());
} }
} }
bool hasAssumedValidChain() override bool hasAssumedValidChain() override
+2 -2
View File
@@ -986,7 +986,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_sync_tx_invalid_state_test, TestingSetup)
mtx.vin.clear(); mtx.vin.clear();
mtx.vin.push_back(CTxIn(tx_id_to_spend, 0)); 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(); const uint256& good_tx_id = mtx.GetHash();
{ {
@@ -1007,7 +1007,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_sync_tx_invalid_state_test, TestingSetup)
static_cast<FailDatabase&>(wallet.GetDatabase()).m_pass = false; static_cast<FailDatabase&>(wallet.GetDatabase()).m_pass = false;
mtx.vin.clear(); mtx.vin.clear();
mtx.vin.push_back(CTxIn(good_tx_id, 0)); 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, std::runtime_error,
HasReason("DB error adding transaction to wallet, write failed")); HasReason("DB error adding transaction to wallet, write failed"));
} }
+3 -3
View File
@@ -1355,7 +1355,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const SyncTxState& sta
MarkInputsDirty(ptx); MarkInputsDirty(ptx);
} }
void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) { void CWallet::transactionAddedToMempool(const CTransactionRef& tx) {
LOCK(cs_wallet); LOCK(cs_wallet);
SyncTransaction(tx, TxStateInMempool{}); SyncTransaction(tx, TxStateInMempool{});
@@ -1365,7 +1365,7 @@ void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t memp
} }
} }
void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) { void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {
LOCK(cs_wallet); LOCK(cs_wallet);
auto it = mapWallet.find(tx->GetHash()); auto it = mapWallet.find(tx->GetHash());
if (it != mapWallet.end()) { if (it != mapWallet.end()) {
@@ -1411,7 +1411,7 @@ void CWallet::blockConnected(const interfaces::BlockInfo& block)
m_last_block_processed = block.hash; m_last_block_processed = block.hash;
for (size_t index = 0; index < block.data->vtx.size(); index++) { for (size_t index = 0; index < block.data->vtx.size(); index++) {
SyncTransaction(block.data->vtx[index], TxStateConfirmed{block.hash, block.height, static_cast<int>(index)}); SyncTransaction(block.data->vtx[index], TxStateConfirmed{block.hash, block.height, static_cast<int>(index)});
transactionRemovedFromMempool(block.data->vtx[index], MemPoolRemovalReason::BLOCK, /*mempool_sequence=*/0); transactionRemovedFromMempool(block.data->vtx[index], MemPoolRemovalReason::BLOCK);
} }
} }
+2 -2
View File
@@ -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); 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); 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 blockConnected(const interfaces::BlockInfo& block) override;
void blockDisconnected(const interfaces::BlockInfo& block) override; void blockDisconnected(const interfaces::BlockInfo& block) override;
void updatedBlockTip() override; void updatedBlockTip() override;
@@ -538,7 +538,7 @@ public:
uint256 last_failed_block; uint256 last_failed_block;
}; };
ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate, const bool save_progress); ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, std::optional<int> 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. */ /** 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(); } void SetNextResend() { m_next_resend = GetDefaultNextResend(); }
/** Return true if all conditions for periodically resending transactions are met. */ /** Return true if all conditions for periodically resending transactions are met. */