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
This commit is contained in:
commit
2d16fb7a2b
1 changed files with 4 additions and 1 deletions
|
@ -486,7 +486,10 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose)
|
||||||
const uint256& hash = e.GetTx().GetHash();
|
const uint256& hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
entryToJSON(pool, info, e);
|
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;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue