aboutsummaryrefslogtreecommitdiff
path: root/src/rest.cpp
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2022-05-23 16:19:44 -0400
committerCarl Dong <contact@carldong.me>2022-06-15 17:28:55 -0400
commit319f0ceeeb25f28e027fc41be2755092dc5365b4 (patch)
treefda9e2134085aecdef38a7f0460b9bf2f04c4270 /src/rest.cpp
parent03574b956a274207ba90591781e0914609225136 (diff)
rest/getutxos: Don't construct empty mempool
...just don't try to consult it at all when fCheckMemPool is false
Diffstat (limited to 'src/rest.cpp')
-rw-r--r--src/rest.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rest.cpp b/src/rest.cpp
index 1b90baaf95..43c248b03b 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -799,10 +799,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
if (!maybe_chainman) return false;
ChainstateManager& chainman = *maybe_chainman;
{
- auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) {
+ auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool* mempool) {
for (const COutPoint& vOutPoint : vOutPoints) {
Coin coin;
- bool hit = !mempool.isSpent(vOutPoint) && view.GetCoin(vOutPoint, coin);
+ bool hit = (!mempool || !mempool->isSpent(vOutPoint)) && view.GetCoin(vOutPoint, coin);
hits.push_back(hit);
if (hit) outs.emplace_back(std::move(coin));
}
@@ -815,10 +815,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
LOCK2(cs_main, mempool->cs);
CCoinsViewCache& viewChain = chainman.ActiveChainstate().CoinsTip();
CCoinsViewMemPool viewMempool(&viewChain, *mempool);
- process_utxos(viewMempool, *mempool);
+ process_utxos(viewMempool, mempool);
} else {
- LOCK(cs_main); // no need to lock mempool!
- process_utxos(chainman.ActiveChainstate().CoinsTip(), CTxMemPool());
+ LOCK(cs_main);
+ process_utxos(chainman.ActiveChainstate().CoinsTip(), nullptr);
}
for (size_t i = 0; i < hits.size(); ++i) {