@@ -405,9 +405,9 @@ static std::string EntryDescriptionString()
405
405
" \" bip125-replaceable\" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)\n " ;
406
406
}
407
407
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)
409
409
{
410
- AssertLockHeld (mempool .cs );
410
+ AssertLockHeld (pool .cs );
411
411
412
412
UniValue fees (UniValue::VOBJ);
413
413
fees.pushKV (" base" , ValueFromAmount (e.GetFee ()));
@@ -427,12 +427,12 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
427
427
info.pushKV (" ancestorcount" , e.GetCountWithAncestors ());
428
428
info.pushKV (" ancestorsize" , e.GetSizeWithAncestors ());
429
429
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 ());
431
431
const CTransaction& tx = e.GetTx ();
432
432
std::set<std::string> setDepends;
433
433
for (const CTxIn& txin : tx.vin )
434
434
{
435
- if (mempool .exists (txin.prevout .hash ))
435
+ if (pool .exists (txin.prevout .hash ))
436
436
setDepends.insert (txin.prevout .hash .ToString ());
437
437
}
438
438
@@ -445,8 +445,8 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
445
445
info.pushKV (" depends" , depends);
446
446
447
447
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);
450
450
for (CTxMemPool::txiter childiter : setChildren) {
451
451
spent.push_back (childiter->GetTx ().GetHash ().ToString ());
452
452
}
@@ -455,7 +455,7 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
455
455
456
456
// Add opt-in RBF status
457
457
bool rbfStatus = false ;
458
- RBFTransactionState rbfState = IsRBFOptIn (tx, mempool );
458
+ RBFTransactionState rbfState = IsRBFOptIn (tx, pool );
459
459
if (rbfState == RBFTransactionState::UNKNOWN) {
460
460
throw JSONRPCError (RPC_MISC_ERROR, " Transaction is not in mempool" );
461
461
} else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) {
@@ -465,25 +465,21 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
465
465
info.pushKV (" bip125-replaceable" , rbfStatus);
466
466
}
467
467
468
- UniValue mempoolToJSON ( bool fVerbose )
468
+ UniValue MempoolToJSON ( const CTxMemPool& pool, bool verbose )
469
469
{
470
- if (fVerbose )
471
- {
472
- LOCK (mempool.cs );
470
+ if (verbose) {
471
+ LOCK (pool.cs );
473
472
UniValue o (UniValue::VOBJ);
474
- for (const CTxMemPoolEntry& e : mempool.mapTx )
475
- {
473
+ for (const CTxMemPoolEntry& e : pool.mapTx ) {
476
474
const uint256& hash = e.GetTx ().GetHash ();
477
475
UniValue info (UniValue::VOBJ);
478
- entryToJSON (info, e);
476
+ entryToJSON (pool, info, e);
479
477
o.pushKV (hash.ToString (), info);
480
478
}
481
479
return o;
482
- }
483
- else
484
- {
480
+ } else {
485
481
std::vector<uint256> vtxid;
486
- mempool .queryHashes (vtxid);
482
+ pool .queryHashes (vtxid);
487
483
488
484
UniValue a (UniValue::VARR);
489
485
for (const uint256& hash : vtxid)
@@ -525,7 +521,7 @@ static UniValue getrawmempool(const JSONRPCRequest& request)
525
521
if (!request.params [0 ].isNull ())
526
522
fVerbose = request.params [0 ].get_bool ();
527
523
528
- return mempoolToJSON ( fVerbose );
524
+ return MempoolToJSON (::mempool, fVerbose );
529
525
}
530
526
531
527
static UniValue getmempoolancestors (const JSONRPCRequest& request)
@@ -591,7 +587,7 @@ static UniValue getmempoolancestors(const JSONRPCRequest& request)
591
587
const CTxMemPoolEntry &e = *ancestorIt;
592
588
const uint256& _hash = e.GetTx ().GetHash ();
593
589
UniValue info (UniValue::VOBJ);
594
- entryToJSON (info, e);
590
+ entryToJSON (::mempool, info, e);
595
591
o.pushKV (_hash.ToString (), info);
596
592
}
597
593
return o;
@@ -661,7 +657,7 @@ static UniValue getmempooldescendants(const JSONRPCRequest& request)
661
657
const CTxMemPoolEntry &e = *descendantIt;
662
658
const uint256& _hash = e.GetTx ().GetHash ();
663
659
UniValue info (UniValue::VOBJ);
664
- entryToJSON (info, e);
660
+ entryToJSON (::mempool, info, e);
665
661
o.pushKV (_hash.ToString (), info);
666
662
}
667
663
return o;
@@ -700,7 +696,7 @@ static UniValue getmempoolentry(const JSONRPCRequest& request)
700
696
701
697
const CTxMemPoolEntry &e = *it;
702
698
UniValue info (UniValue::VOBJ);
703
- entryToJSON (info, e);
699
+ entryToJSON (::mempool, info, e);
704
700
return info;
705
701
}
706
702
@@ -1485,15 +1481,15 @@ static UniValue getchaintips(const JSONRPCRequest& request)
1485
1481
return res;
1486
1482
}
1487
1483
1488
- UniValue mempoolInfoToJSON ( )
1484
+ UniValue MempoolInfoToJSON ( const CTxMemPool& pool )
1489
1485
{
1490
1486
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 ());
1494
1490
size_t maxmempool = gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 ;
1495
1491
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 ()));
1497
1493
ret.pushKV (" minrelaytxfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ()));
1498
1494
1499
1495
return ret;
@@ -1522,7 +1518,7 @@ static UniValue getmempoolinfo(const JSONRPCRequest& request)
1522
1518
},
1523
1519
}.ToString ());
1524
1520
1525
- return mempoolInfoToJSON ( );
1521
+ return MempoolInfoToJSON (::mempool );
1526
1522
}
1527
1523
1528
1524
static UniValue preciousblock (const JSONRPCRequest& request)
0 commit comments