@@ -405,9 +405,9 @@ static std::string EntryDescriptionString()
405405 " \" bip125-replaceable\" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)\n " ;
406406}
407407
408- static void entryToJSON (UniValue & info, const CTxMemPoolEntry & e) EXCLUSIVE_LOCKS_REQUIRED(::mempool .cs)
408+ static void entryToJSON (const CTxMemPool& pool, UniValue& info, const CTxMemPoolEntry& e) EXCLUSIVE_LOCKS_REQUIRED(pool .cs)
409409{
410- AssertLockHeld (mempool .cs );
410+ AssertLockHeld (pool .cs );
411411
412412 UniValue fees (UniValue::VOBJ);
413413 fees.pushKV (" base" , ValueFromAmount (e.GetFee ()));
@@ -427,12 +427,12 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
427427 info.pushKV (" ancestorcount" , e.GetCountWithAncestors ());
428428 info.pushKV (" ancestorsize" , e.GetSizeWithAncestors ());
429429 info.pushKV (" ancestorfees" , e.GetModFeesWithAncestors ());
430- info.pushKV (" wtxid" , mempool .vTxHashes [e.vTxHashesIdx ].first .ToString ());
430+ info.pushKV (" wtxid" , pool .vTxHashes [e.vTxHashesIdx ].first .ToString ());
431431 const CTransaction& tx = e.GetTx ();
432432 std::set<std::string> setDepends;
433433 for (const CTxIn& txin : tx.vin )
434434 {
435- if (mempool .exists (txin.prevout .hash ))
435+ if (pool .exists (txin.prevout .hash ))
436436 setDepends.insert (txin.prevout .hash .ToString ());
437437 }
438438
@@ -445,8 +445,8 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
445445 info.pushKV (" depends" , depends);
446446
447447 UniValue spent (UniValue::VARR);
448- const CTxMemPool::txiter & it = mempool .mapTx .find (tx.GetHash ());
449- const CTxMemPool::setEntries & setChildren = mempool .GetMemPoolChildren (it);
448+ const CTxMemPool::txiter& it = pool .mapTx .find (tx.GetHash ());
449+ const CTxMemPool::setEntries& setChildren = pool .GetMemPoolChildren (it);
450450 for (CTxMemPool::txiter childiter : setChildren) {
451451 spent.push_back (childiter->GetTx ().GetHash ().ToString ());
452452 }
@@ -455,7 +455,7 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
455455
456456 // Add opt-in RBF status
457457 bool rbfStatus = false ;
458- RBFTransactionState rbfState = IsRBFOptIn (tx, mempool );
458+ RBFTransactionState rbfState = IsRBFOptIn (tx, pool );
459459 if (rbfState == RBFTransactionState::UNKNOWN) {
460460 throw JSONRPCError (RPC_MISC_ERROR, " Transaction is not in mempool" );
461461 } else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) {
@@ -465,25 +465,21 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
465465 info.pushKV (" bip125-replaceable" , rbfStatus);
466466}
467467
468- UniValue mempoolToJSON ( bool fVerbose )
468+ UniValue MempoolToJSON ( const CTxMemPool& pool, bool verbose )
469469{
470- if (fVerbose )
471- {
472- LOCK (mempool.cs );
470+ if (verbose) {
471+ LOCK (pool.cs );
473472 UniValue o (UniValue::VOBJ);
474- for (const CTxMemPoolEntry& e : mempool.mapTx )
475- {
473+ for (const CTxMemPoolEntry& e : pool.mapTx ) {
476474 const uint256& hash = e.GetTx ().GetHash ();
477475 UniValue info (UniValue::VOBJ);
478- entryToJSON (info, e);
476+ entryToJSON (pool, info, e);
479477 o.pushKV (hash.ToString (), info);
480478 }
481479 return o;
482- }
483- else
484- {
480+ } else {
485481 std::vector<uint256> vtxid;
486- mempool .queryHashes (vtxid);
482+ pool .queryHashes (vtxid);
487483
488484 UniValue a (UniValue::VARR);
489485 for (const uint256& hash : vtxid)
@@ -525,7 +521,7 @@ static UniValue getrawmempool(const JSONRPCRequest& request)
525521 if (!request.params [0 ].isNull ())
526522 fVerbose = request.params [0 ].get_bool ();
527523
528- return mempoolToJSON ( fVerbose );
524+ return MempoolToJSON (::mempool, fVerbose );
529525}
530526
531527static UniValue getmempoolancestors (const JSONRPCRequest& request)
@@ -591,7 +587,7 @@ static UniValue getmempoolancestors(const JSONRPCRequest& request)
591587 const CTxMemPoolEntry &e = *ancestorIt;
592588 const uint256& _hash = e.GetTx ().GetHash ();
593589 UniValue info (UniValue::VOBJ);
594- entryToJSON (info, e);
590+ entryToJSON (::mempool, info, e);
595591 o.pushKV (_hash.ToString (), info);
596592 }
597593 return o;
@@ -661,7 +657,7 @@ static UniValue getmempooldescendants(const JSONRPCRequest& request)
661657 const CTxMemPoolEntry &e = *descendantIt;
662658 const uint256& _hash = e.GetTx ().GetHash ();
663659 UniValue info (UniValue::VOBJ);
664- entryToJSON (info, e);
660+ entryToJSON (::mempool, info, e);
665661 o.pushKV (_hash.ToString (), info);
666662 }
667663 return o;
@@ -700,7 +696,7 @@ static UniValue getmempoolentry(const JSONRPCRequest& request)
700696
701697 const CTxMemPoolEntry &e = *it;
702698 UniValue info (UniValue::VOBJ);
703- entryToJSON (info, e);
699+ entryToJSON (::mempool, info, e);
704700 return info;
705701}
706702
@@ -1485,15 +1481,15 @@ static UniValue getchaintips(const JSONRPCRequest& request)
14851481 return res;
14861482}
14871483
1488- UniValue mempoolInfoToJSON ( )
1484+ UniValue MempoolInfoToJSON ( const CTxMemPool& pool )
14891485{
14901486 UniValue ret (UniValue::VOBJ);
1491- ret.pushKV (" size" , (int64_t ) mempool .size ());
1492- ret.pushKV (" bytes" , (int64_t ) mempool .GetTotalTxSize ());
1493- ret.pushKV (" usage" , (int64_t ) mempool .DynamicMemoryUsage ());
1487+ ret.pushKV (" size" , (int64_t )pool .size ());
1488+ ret.pushKV (" bytes" , (int64_t )pool .GetTotalTxSize ());
1489+ ret.pushKV (" usage" , (int64_t )pool .DynamicMemoryUsage ());
14941490 size_t maxmempool = gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 ;
14951491 ret.pushKV (" maxmempool" , (int64_t ) maxmempool);
1496- ret.pushKV (" mempoolminfee" , ValueFromAmount (std::max (mempool .GetMinFee (maxmempool), ::minRelayTxFee).GetFeePerK ()));
1492+ ret.pushKV (" mempoolminfee" , ValueFromAmount (std::max (pool .GetMinFee (maxmempool), ::minRelayTxFee).GetFeePerK ()));
14971493 ret.pushKV (" minrelaytxfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ()));
14981494
14991495 return ret;
@@ -1522,7 +1518,7 @@ static UniValue getmempoolinfo(const JSONRPCRequest& request)
15221518 },
15231519 }.ToString ());
15241520
1525- return mempoolInfoToJSON ( );
1521+ return MempoolInfoToJSON (::mempool );
15261522}
15271523
15281524static UniValue preciousblock (const JSONRPCRequest& request)
0 commit comments