mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
scripted-diff: Following the C++ Standard rules for identifiers with _.
Any identifier starting with two _, or one _ followed by a capital letter is reserved for the compiler and thus must not be used. See: https://stackoverflow.com/a/228797/7130273 -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-
This commit is contained in:
parent
8f40271037
commit
bdea2bb114
13 changed files with 26 additions and 26 deletions
|
@ -115,7 +115,7 @@ bool WriteSettings(const fs::path& path,
|
||||||
{
|
{
|
||||||
SettingsValue out(SettingsValue::VOBJ);
|
SettingsValue out(SettingsValue::VOBJ);
|
||||||
for (const auto& value : values) {
|
for (const auto& value : values) {
|
||||||
out.__pushKV(value.first, value.second);
|
out.pushKVEnd(value.first, value.second);
|
||||||
}
|
}
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
file.open(path);
|
file.open(path);
|
||||||
|
|
|
@ -371,10 +371,10 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!positional_args.empty()) {
|
if (!positional_args.empty()) {
|
||||||
// Use __pushKV instead of pushKV to avoid overwriting an explicit
|
// Use pushKVEnd instead of pushKV to avoid overwriting an explicit
|
||||||
// "args" value with an implicit one. Let the RPC server handle the
|
// "args" value with an implicit one. Let the RPC server handle the
|
||||||
// request as given.
|
// request as given.
|
||||||
params.__pushKV("args", positional_args);
|
params.pushKVEnd("args", positional_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
|
|
|
@ -351,8 +351,8 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
|
||||||
entryToJSON(pool, info, e);
|
entryToJSON(pool, info, e);
|
||||||
// Mempool has unique entries so there is no advantage in using
|
// 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, which checks if the key already exists in O(N).
|
||||||
// UniValue::__pushKV is used instead which currently is O(1).
|
// UniValue::pushKVEnd is used instead which currently is O(1).
|
||||||
o.__pushKV(hash.ToString(), info);
|
o.pushKVEnd(hash.ToString(), info);
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -437,7 +437,7 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
|
||||||
if (options.exists(fr->first)) {
|
if (options.exists(fr->first)) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " specified multiple times");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter " + fr->first + " specified multiple times");
|
||||||
}
|
}
|
||||||
options.__pushKV(fr->first, *fr->second);
|
options.pushKVEnd(fr->first, *fr->second);
|
||||||
argsIn.erase(fr);
|
argsIn.erase(fr);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -32,9 +32,9 @@ struct secure_allocator : public std::allocator<T> {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~secure_allocator() noexcept {}
|
~secure_allocator() noexcept {}
|
||||||
template <typename _Other>
|
template <typename Other>
|
||||||
struct rebind {
|
struct rebind {
|
||||||
typedef secure_allocator<_Other> other;
|
typedef secure_allocator<Other> other;
|
||||||
};
|
};
|
||||||
|
|
||||||
T* allocate(std::size_t n, const void* hint = nullptr)
|
T* allocate(std::size_t n, const void* hint = nullptr)
|
||||||
|
|
|
@ -27,9 +27,9 @@ struct zero_after_free_allocator : public std::allocator<T> {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~zero_after_free_allocator() noexcept {}
|
~zero_after_free_allocator() noexcept {}
|
||||||
template <typename _Other>
|
template <typename Other>
|
||||||
struct rebind {
|
struct rebind {
|
||||||
typedef zero_after_free_allocator<_Other> other;
|
typedef zero_after_free_allocator<Other> other;
|
||||||
};
|
};
|
||||||
|
|
||||||
void deallocate(T* p, std::size_t n)
|
void deallocate(T* p, std::size_t n)
|
||||||
|
|
|
@ -35,7 +35,7 @@ inline std::ostream& operator<<(std::ostream& os, const common::SettingsValue& v
|
||||||
inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, common::SettingsValue>& kv)
|
inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, common::SettingsValue>& kv)
|
||||||
{
|
{
|
||||||
common::SettingsValue out(common::SettingsValue::VOBJ);
|
common::SettingsValue out(common::SettingsValue::VOBJ);
|
||||||
out.__pushKV(kv.first, kv.second);
|
out.pushKVEnd(kv.first, kv.second);
|
||||||
os << out.write();
|
os << out.write();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,10 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
|
||||||
int TxOrphanage::EraseTx(const uint256& txid)
|
int TxOrphanage::EraseTx(const uint256& txid)
|
||||||
{
|
{
|
||||||
LOCK(m_mutex);
|
LOCK(m_mutex);
|
||||||
return _EraseTx(txid);
|
return EraseTxNoLock(txid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TxOrphanage::_EraseTx(const uint256& txid)
|
int TxOrphanage::EraseTxNoLock(const uint256& txid)
|
||||||
{
|
{
|
||||||
AssertLockHeld(m_mutex);
|
AssertLockHeld(m_mutex);
|
||||||
std::map<uint256, OrphanTx>::iterator it = m_orphans.find(txid);
|
std::map<uint256, OrphanTx>::iterator it = m_orphans.find(txid);
|
||||||
|
@ -103,7 +103,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
|
||||||
std::map<uint256, OrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
|
std::map<uint256, OrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
|
||||||
if (maybeErase->second.fromPeer == peer)
|
if (maybeErase->second.fromPeer == peer)
|
||||||
{
|
{
|
||||||
nErased += _EraseTx(maybeErase->second.tx->GetHash());
|
nErased += EraseTxNoLock(maybeErase->second.tx->GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, peer);
|
if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, peer);
|
||||||
|
@ -125,7 +125,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans)
|
||||||
{
|
{
|
||||||
std::map<uint256, OrphanTx>::iterator maybeErase = iter++;
|
std::map<uint256, OrphanTx>::iterator maybeErase = iter++;
|
||||||
if (maybeErase->second.nTimeExpire <= nNow) {
|
if (maybeErase->second.nTimeExpire <= nNow) {
|
||||||
nErased += _EraseTx(maybeErase->second.tx->GetHash());
|
nErased += EraseTxNoLock(maybeErase->second.tx->GetHash());
|
||||||
} else {
|
} else {
|
||||||
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
|
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans)
|
||||||
{
|
{
|
||||||
// Evict a random orphan:
|
// Evict a random orphan:
|
||||||
size_t randompos = rng.randrange(m_orphan_list.size());
|
size_t randompos = rng.randrange(m_orphan_list.size());
|
||||||
_EraseTx(m_orphan_list[randompos]->first);
|
EraseTxNoLock(m_orphan_list[randompos]->first);
|
||||||
++nEvicted;
|
++nEvicted;
|
||||||
}
|
}
|
||||||
if (nEvicted > 0) LogPrint(BCLog::MEMPOOL, "orphanage overflow, removed %u tx\n", nEvicted);
|
if (nEvicted > 0) LogPrint(BCLog::MEMPOOL, "orphanage overflow, removed %u tx\n", nEvicted);
|
||||||
|
@ -231,7 +231,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
|
||||||
if (vOrphanErase.size()) {
|
if (vOrphanErase.size()) {
|
||||||
int nErased = 0;
|
int nErased = 0;
|
||||||
for (const uint256& orphanHash : vOrphanErase) {
|
for (const uint256& orphanHash : vOrphanErase) {
|
||||||
nErased += _EraseTx(orphanHash);
|
nErased += EraseTxNoLock(orphanHash);
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ protected:
|
||||||
std::map<uint256, OrphanMap::iterator> m_wtxid_to_orphan_it GUARDED_BY(m_mutex);
|
std::map<uint256, OrphanMap::iterator> m_wtxid_to_orphan_it GUARDED_BY(m_mutex);
|
||||||
|
|
||||||
/** Erase an orphan by txid */
|
/** Erase an orphan by txid */
|
||||||
int _EraseTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
|
int EraseTxNoLock(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_TXORPHANAGE_H
|
#endif // BITCOIN_TXORPHANAGE_H
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
template <class It>
|
template <class It>
|
||||||
void push_backV(It first, It last);
|
void push_backV(It first, It last);
|
||||||
|
|
||||||
void __pushKV(std::string key, UniValue val);
|
void pushKVEnd(std::string key, UniValue val);
|
||||||
void pushKV(std::string key, UniValue val);
|
void pushKV(std::string key, UniValue val);
|
||||||
void pushKVs(UniValue obj);
|
void pushKVs(UniValue obj);
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void UniValue::push_backV(const std::vector<UniValue>& vec)
|
||||||
values.insert(values.end(), vec.begin(), vec.end());
|
values.insert(values.end(), vec.begin(), vec.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniValue::__pushKV(std::string key, UniValue val)
|
void UniValue::pushKVEnd(std::string key, UniValue val)
|
||||||
{
|
{
|
||||||
checkType(VOBJ);
|
checkType(VOBJ);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ void UniValue::pushKV(std::string key, UniValue val)
|
||||||
if (findKey(key, idx))
|
if (findKey(key, idx))
|
||||||
values[idx] = std::move(val);
|
values[idx] = std::move(val);
|
||||||
else
|
else
|
||||||
__pushKV(std::move(key), std::move(val));
|
pushKVEnd(std::move(key), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniValue::pushKVs(UniValue obj)
|
void UniValue::pushKVs(UniValue obj)
|
||||||
|
@ -140,7 +140,7 @@ void UniValue::pushKVs(UniValue obj)
|
||||||
obj.checkType(VOBJ);
|
obj.checkType(VOBJ);
|
||||||
|
|
||||||
for (size_t i = 0; i < obj.keys.size(); i++)
|
for (size_t i = 0; i < obj.keys.size(); i++)
|
||||||
__pushKV(std::move(obj.keys.at(i)), std::move(obj.values.at(i)));
|
pushKVEnd(std::move(obj.keys.at(i)), std::move(obj.values.at(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniValue::getObjMap(std::map<std::string,UniValue>& kv) const
|
void UniValue::getObjMap(std::map<std::string,UniValue>& kv) const
|
||||||
|
|
|
@ -86,7 +86,7 @@ void univalue_push_throw()
|
||||||
UniValue j;
|
UniValue j;
|
||||||
BOOST_CHECK_THROW(j.push_back(1), std::runtime_error);
|
BOOST_CHECK_THROW(j.push_back(1), std::runtime_error);
|
||||||
BOOST_CHECK_THROW(j.push_backV({1}), std::runtime_error);
|
BOOST_CHECK_THROW(j.push_backV({1}), std::runtime_error);
|
||||||
BOOST_CHECK_THROW(j.__pushKV("k", 1), std::runtime_error);
|
BOOST_CHECK_THROW(j.pushKVEnd("k", 1), std::runtime_error);
|
||||||
BOOST_CHECK_THROW(j.pushKV("k", 1), std::runtime_error);
|
BOOST_CHECK_THROW(j.pushKV("k", 1), std::runtime_error);
|
||||||
BOOST_CHECK_THROW(j.pushKVs({}), std::runtime_error);
|
BOOST_CHECK_THROW(j.pushKVs({}), std::runtime_error);
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ void univalue_object()
|
||||||
obj.setObject();
|
obj.setObject();
|
||||||
UniValue uv;
|
UniValue uv;
|
||||||
uv.setInt(42);
|
uv.setInt(42);
|
||||||
obj.__pushKV("age", uv);
|
obj.pushKVEnd("age", uv);
|
||||||
BOOST_CHECK_EQUAL(obj.size(), 1);
|
BOOST_CHECK_EQUAL(obj.size(), 1);
|
||||||
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "42");
|
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "42");
|
||||||
|
|
||||||
|
|
|
@ -677,11 +677,11 @@ RPCHelpMan getaddressesbylabel()
|
||||||
CHECK_NONFATAL(unique);
|
CHECK_NONFATAL(unique);
|
||||||
// UniValue::pushKV checks if the key exists in O(N)
|
// UniValue::pushKV checks if the key exists in O(N)
|
||||||
// and since duplicate addresses are unexpected (checked with
|
// and since duplicate addresses are unexpected (checked with
|
||||||
// std::set in O(log(N))), UniValue::__pushKV is used instead,
|
// std::set in O(log(N))), UniValue::pushKVEnd is used instead,
|
||||||
// which currently is O(1).
|
// which currently is O(1).
|
||||||
UniValue value(UniValue::VOBJ);
|
UniValue value(UniValue::VOBJ);
|
||||||
value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown");
|
value.pushKV("purpose", _purpose ? PurposeToString(*_purpose) : "unknown");
|
||||||
ret.__pushKV(address, value);
|
ret.pushKVEnd(address, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue