Skip to content

Commit 2d5cf4c

Browse files
promagMarcoFalke
andcommitted
rpc: Speedup getrawmempool when verbose=true
Co-Authored-By: MarcoFalke <[email protected]>
1 parent efed980 commit 2d5cf4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/rpc/blockchain.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose)
474474
const uint256& hash = e.GetTx().GetHash();
475475
UniValue info(UniValue::VOBJ);
476476
entryToJSON(pool, info, e);
477-
o.pushKV(hash.ToString(), info);
477+
// Mempool has unique entries so there is no advantage in using
478+
// UniValue::pushKV, which checks if the key already exists in O(N).
479+
// UniValue::__pushKV is used instead which currently is O(1).
480+
o.__pushKV(hash.ToString(), info);
478481
}
479482
return o;
480483
} else {

0 commit comments

Comments
 (0)