From 291276f7f40df9fcd62e54c016953705bf0ed04a Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Fri, 28 Jul 2017 19:29:50 -0400 Subject: [PATCH] Remove use of GetCountWithDescendants in wallet code This commit does not change behavior. --- src/interfaces/chain.cpp | 6 ++++++ src/interfaces/chain.h | 3 +++ src/wallet/feebumper.cpp | 4 +--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index 7cab303aa..8c5921970 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -190,6 +190,12 @@ public: LOCK(::mempool.cs); return IsRBFOptIn(tx, ::mempool); } + bool hasDescendantsInMempool(const uint256& txid) override + { + LOCK(::mempool.cs); + auto it_mp = ::mempool.mapTx.find(txid); + return it_mp != ::mempool.mapTx.end() && it_mp->GetCountWithDescendants() > 1; + } }; } // namespace diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 486f1ea16..aa4f17a8e 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -135,6 +135,9 @@ public: //! Check if transaction is RBF opt in. virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0; + + //! Check if transaction has descendants in mempool. + virtual bool hasDescendantsInMempool(const uint256& txid) = 0; }; //! Interface to let node manage chain clients (wallets, or maybe tools for diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 7a71aea71..f4b419ca2 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -27,9 +27,7 @@ static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chai } { - LOCK(mempool.cs); - auto it_mp = mempool.mapTx.find(wtx.GetHash()); - if (it_mp != mempool.mapTx.end() && it_mp->GetCountWithDescendants() > 1) { + if (wallet->chain().hasDescendantsInMempool(wtx.GetHash())) { errors.push_back("Transaction has descendants in the mempool"); return feebumper::Result::INVALID_PARAMETER; }