diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp --- a/src/bench/rpc_mempool.cpp +++ b/src/bench/rpc_mempool.cpp @@ -46,4 +46,4 @@ } } -BENCHMARK(RpcMempool, 3); +BENCHMARK(RpcMempool, 6); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -484,23 +484,26 @@ AssertLockHeld(pool.cs); UniValue fees(UniValue::VOBJ); - fees.pushKV("base", ValueFromAmount(e.GetFee())); - fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee())); - fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors())); - fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants())); - info.pushKV("fees", fees); - - info.pushKV("size", (int)e.GetTxSize()); - info.pushKV("fee", ValueFromAmount(e.GetFee())); - info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee())); - info.pushKV("time", e.GetTime()); - info.pushKV("height", (int)e.GetHeight()); - info.pushKV("descendantcount", e.GetCountWithDescendants()); - info.pushKV("descendantsize", e.GetSizeWithDescendants()); - info.pushKV("descendantfees", e.GetModFeesWithDescendants() / SATOSHI); - info.pushKV("ancestorcount", e.GetCountWithAncestors()); - info.pushKV("ancestorsize", e.GetSizeWithAncestors()); - info.pushKV("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI); + fees.pushKV("base", ValueFromAmount(e.GetFee()), false); + fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee()), false); + fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors()), + false); + fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants()), + false); + info.pushKV("fees", fees, false); + + info.pushKV("size", (int)e.GetTxSize(), false); + info.pushKV("fee", ValueFromAmount(e.GetFee()), false); + info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee()), false); + info.pushKV("time", e.GetTime(), false); + info.pushKV("height", (int)e.GetHeight(), false); + info.pushKV("descendantcount", e.GetCountWithDescendants(), false); + info.pushKV("descendantsize", e.GetSizeWithDescendants(), false); + info.pushKV("descendantfees", e.GetModFeesWithDescendants() / SATOSHI, + false); + info.pushKV("ancestorcount", e.GetCountWithAncestors(), false); + info.pushKV("ancestorsize", e.GetSizeWithAncestors(), false); + info.pushKV("ancestorfees", e.GetModFeesWithAncestors() / SATOSHI, false); const CTransaction &tx = e.GetTx(); std::set setDepends; for (const CTxIn &txin : tx.vin) { @@ -514,7 +517,7 @@ depends.push_back(dep); } - info.pushKV("depends", depends); + info.pushKV("depends", depends, false); UniValue spent(UniValue::VARR); const CTxMemPool::txiter &it = pool.mapTx.find(tx.GetId()); @@ -523,7 +526,7 @@ spent.push_back(childiter->GetTx().GetId().ToString()); } - info.pushKV("spentby", spent); + info.pushKV("spentby", spent, false); } UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose) { @@ -534,7 +537,7 @@ const uint256 &txid = e.GetTx().GetId(); UniValue info(UniValue::VOBJ); entryToJSON(pool, info, e); - o.pushKV(txid.ToString(), info); + o.pushKV(txid.ToString(), info, false); } return o; } else { diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -112,34 +112,34 @@ bool push_backV(const std::vector& vec); void __pushKV(const std::string& key, const UniValue& val); - bool pushKV(const std::string& key, const UniValue& val); - bool pushKV(const std::string& key, const std::string& val_) { + bool pushKV(const std::string& key, const UniValue& val, bool checkForDuplicates = true); + bool pushKV(const std::string& key, const std::string& val_, bool checkForDuplicates = true) { UniValue tmpVal(VSTR, val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } - bool pushKV(const std::string& key, const char *val_) { + bool pushKV(const std::string& key, const char *val_, bool checkForDuplicates = true) { std::string _val(val_); - return pushKV(key, _val); + return pushKV(key, _val, checkForDuplicates); } - bool pushKV(const std::string& key, int64_t val_) { + bool pushKV(const std::string& key, int64_t val_, bool checkForDuplicates = true) { UniValue tmpVal(val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } - bool pushKV(const std::string& key, uint64_t val_) { + bool pushKV(const std::string& key, uint64_t val_, bool checkForDuplicates = true) { UniValue tmpVal(val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } - bool pushKV(const std::string& key, bool val_) { + bool pushKV(const std::string& key, bool val_, bool checkForDuplicates = true) { UniValue tmpVal((bool)val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } - bool pushKV(const std::string& key, int val_) { + bool pushKV(const std::string& key, int val_, bool checkForDuplicates = true) { UniValue tmpVal((int64_t)val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } - bool pushKV(const std::string& key, double val_) { + bool pushKV(const std::string& key, double val_, bool checkForDuplicates = true) { UniValue tmpVal(val_); - return pushKV(key, tmpVal); + return pushKV(key, tmpVal, checkForDuplicates); } bool pushKVs(const UniValue& obj); diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp --- a/src/univalue/lib/univalue.cpp +++ b/src/univalue/lib/univalue.cpp @@ -130,13 +130,13 @@ values.push_back(val_); } -bool UniValue::pushKV(const std::string& key, const UniValue& val_) +bool UniValue::pushKV(const std::string& key, const UniValue& val_, bool checkForDuplicates) { if (typ != VOBJ) return false; size_t idx; - if (findKey(key, idx)) + if (checkForDuplicates && findKey(key, idx)) values[idx] = val_; else __pushKV(key, val_);