Skip to content

Commit 19e166d

Browse files
committed
scripted-diff: Merge bitcoin#27822 Renamed UniValue::__pushKV to UniValue::pushKVEnd
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s '__pushKV' 'pushKVEnd' s '_EraseTx' 'EraseTxNoLock' s '_Other' 'Other' -END VERIFY SCRIPT-
1 parent 9d9ed5a commit 19e166d

10 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/rpc/client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ UniValue RPCConvertNamedValues(std::string strMethod, const std::vector<std::str
458458
}
459459

460460
if (!positional_args.empty()) {
461-
// Use __pushKV instead of pushKV to avoid overwriting an explicit
461+
// Use pushKVEnd instead of pushKV to avoid overwriting an explicit
462462
// "args" value with an implicit one. Let the RPC server handle the
463463
// request as given.
464-
params.__pushKV("args", positional_args);
464+
params.pushKVEnd("args", positional_args);
465465
}
466466

467467
return params;

src/rpc/mempool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ UniValue MempoolToJSON(const CTxMemPool& pool, const llmq::CInstantSendManager*
346346
entryToJSON(pool, info, e, isman);
347347
// Mempool has unique entries so there is no advantage in using
348348
// UniValue::pushKV, which checks if the key already exists in O(N).
349-
// UniValue::__pushKV is used instead which currently is O(1).
350-
o.__pushKV(hash.ToString(), info);
349+
// UniValue::pushKVEnd is used instead which currently is O(1).
350+
o.pushKVEnd(hash.ToString(), info);
351351
}
352352
return o;
353353
} else {

src/test/settings_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inline std::ostream& operator<<(std::ostream& os, const util::SettingsValue& val
3535
inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, util::SettingsValue>& kv)
3636
{
3737
util::SettingsValue out(util::SettingsValue::VOBJ);
38-
out.__pushKV(kv.first, kv.second);
38+
out.pushKVEnd(kv.first, kv.second);
3939
os << out.write();
4040
return os;
4141
}

src/txorphanage.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
5959
int TxOrphanage::EraseTx(const uint256& txid)
6060
{
6161
LOCK(m_mutex);
62-
return _EraseTx(txid);
62+
return EraseTxNoLock(txid);
6363
}
6464

65-
int TxOrphanage::_EraseTx(const uint256& txid)
65+
int TxOrphanage::EraseTxNoLock(const uint256& txid)
6666
{
6767
AssertLockHeld(m_mutex);
6868
std::map<uint256, OrphanTx>::iterator it = m_orphans.find(txid);
@@ -110,7 +110,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
110110
std::map<uint256, OrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
111111
if (maybeErase->second.fromPeer == peer)
112112
{
113-
nErased += _EraseTx(maybeErase->second.tx->GetHash());
113+
nErased += EraseTxNoLock(maybeErase->second.tx->GetHash());
114114
}
115115
}
116116
if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, peer);
@@ -132,7 +132,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
132132
{
133133
std::map<uint256, OrphanTx>::iterator maybeErase = iter++;
134134
if (maybeErase->second.nTimeExpire <= nNow) {
135-
nErased += _EraseTx(maybeErase->second.tx->GetHash());
135+
nErased += EraseTxNoLock(maybeErase->second.tx->GetHash());
136136
} else {
137137
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
138138
}
@@ -146,7 +146,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
146146
{
147147
// Evict a random orphan:
148148
size_t randompos = rng.randrange(m_orphan_list.size());
149-
_EraseTx(m_orphan_list[randompos]->first);
149+
EraseTxNoLock(m_orphan_list[randompos]->first);
150150
++nEvicted;
151151
}
152152
if (nEvicted > 0) LogPrint(BCLog::MEMPOOL, "orphanage overflow, removed %u tx\n", nEvicted);
@@ -234,7 +234,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
234234
if (vOrphanErase.size()) {
235235
int nErased = 0;
236236
for (const uint256& orphanHash : vOrphanErase) {
237-
nErased += _EraseTx(orphanHash);
237+
nErased += EraseTxNoLock(orphanHash);
238238
}
239239
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
240240
}

src/txorphanage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TxOrphanage {
104104
size_t m_orphan_tx_size GUARDED_BY(m_mutex){0};
105105

106106
/** Erase an orphan by txid */
107-
int _EraseTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
107+
int EraseTxNoLock(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
108108
};
109109

110110
#endif // BITCOIN_TXORPHANAGE_H

src/univalue/include/univalue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class UniValue {
8787
template <class It>
8888
void push_backV(It first, It last);
8989

90-
void __pushKV(std::string key, UniValue val);
90+
void pushKVEnd(std::string key, UniValue val);
9191
void pushKV(std::string key, UniValue val);
9292
void pushKVs(UniValue obj);
9393

src/univalue/lib/univalue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void UniValue::push_backV(const std::vector<UniValue>& vec)
115115
values.insert(values.end(), vec.begin(), vec.end());
116116
}
117117

118-
void UniValue::__pushKV(std::string key, UniValue val)
118+
void UniValue::pushKVEnd(std::string key, UniValue val)
119119
{
120120
checkType(VOBJ);
121121

@@ -131,7 +131,7 @@ void UniValue::pushKV(std::string key, UniValue val)
131131
if (findKey(key, idx))
132132
values[idx] = std::move(val);
133133
else
134-
__pushKV(std::move(key), std::move(val));
134+
pushKVEnd(std::move(key), std::move(val));
135135
}
136136

137137
void UniValue::pushKVs(UniValue obj)
@@ -140,7 +140,7 @@ void UniValue::pushKVs(UniValue obj)
140140
obj.checkType(VOBJ);
141141

142142
for (size_t i = 0; i < obj.keys.size(); i++)
143-
__pushKV(std::move(obj.keys.at(i)), std::move(obj.values.at(i)));
143+
pushKVEnd(std::move(obj.keys.at(i)), std::move(obj.values.at(i)));
144144
}
145145

146146
void UniValue::getObjMap(std::map<std::string,UniValue>& kv) const

src/univalue/test/object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void univalue_push_throw()
8686
UniValue j;
8787
BOOST_CHECK_THROW(j.push_back(1), std::runtime_error);
8888
BOOST_CHECK_THROW(j.push_backV({1}), std::runtime_error);
89-
BOOST_CHECK_THROW(j.__pushKV("k", 1), std::runtime_error);
89+
BOOST_CHECK_THROW(j.pushKVEnd("k", 1), std::runtime_error);
9090
BOOST_CHECK_THROW(j.pushKV("k", 1), std::runtime_error);
9191
BOOST_CHECK_THROW(j.pushKVs({}), std::runtime_error);
9292
}
@@ -364,7 +364,7 @@ void univalue_object()
364364
obj.setObject();
365365
UniValue uv;
366366
uv.setInt(42);
367-
obj.__pushKV("age", uv);
367+
obj.pushKVEnd("age", uv);
368368
BOOST_CHECK_EQUAL(obj.size(), 1);
369369
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "42");
370370

src/util/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bool WriteSettings(const fs::path& path,
124124
{
125125
SettingsValue out(SettingsValue::VOBJ);
126126
for (const auto& value : values) {
127-
out.__pushKV(value.first, value.second);
127+
out.pushKVEnd(value.first, value.second);
128128
}
129129
std::ofstream file;
130130
file.open(path);

src/wallet/rpc/addresses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,11 @@ RPCHelpMan getaddressesbylabel()
608608
CHECK_NONFATAL(unique);
609609
// UniValue::pushKV checks if the key exists in O(N)
610610
// and since duplicate addresses are unexpected (checked with
611-
// std::set in O(log(N))), UniValue::__pushKV is used instead,
611+
// std::set in O(log(N))), UniValue::pushKVEnd is used instead,
612612
// which currently is O(1).
613613
UniValue value(UniValue::VOBJ);
614614
value.pushKV("purpose", _purpose);
615-
ret.__pushKV(address, value);
615+
ret.pushKVEnd(address, value);
616616
}
617617
});
618618

0 commit comments

Comments
 (0)