aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-05-15 11:32:23 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-05-15 11:32:29 -0400
commit2d16fb7a2b6a9e5a2535295d2de03e27c2438d1f (patch)
tree795c54035c96f169eccac7299582fabfa024ced7
parent65526fc8666fef35ef908dbc225f706bef642c7e (diff)
parent2d5cf4c41d86f2bdd1df99edc130ade1d093258f (diff)
Merge #14984: rpc: Speedup getrawmempool when verbose=true
2d5cf4c41d rpc: Speedup getrawmempool when verbose=true (João Barbosa) Pull request description: Instead of calling `pushKV(hash, info)`, which incurs in duplicate key checks, call `__pushKV` which (currently) doesn't. Improves RPC `getrawmempool` and REST `/rest/mempool/contents.json`. Fixes #14765. ACKs for commit 2d5cf4: Tree-SHA512: c3e91371bb41f39e79dcef820815e1dc27fb689ca3c4bf3a00467d2215b3baecd44d9792f7a481577a5b7ae1fc6cbaa07b1cd62123b845082eba65b35c2b3ca5
-rw-r--r--src/rpc/blockchain.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index b8ef758661..56018caf24 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -486,7 +486,10 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose)
const uint256& hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
entryToJSON(pool, info, e);
- o.pushKV(hash.ToString(), info);
+ // Mempool has unique entries so there is no advantage in using
+ // UniValue::pushKV, which checks if the key already exists in O(N).
+ // UniValue::__pushKV is used instead which currently is O(1).
+ o.__pushKV(hash.ToString(), info);
}
return o;
} else {