Match va_start and va_end calls, pointed by clang-tidy #176

Closed
bvbfan wants to merge 277 commits from va_brach into master
5 changed files with 152 additions and 4 deletions
Showing only changes of commit 3862e2f809 - Show all commits

View file

@ -216,7 +216,6 @@ bool CClaimTrie::haveClaim(const std::string& name, const uint256& txhash, uint3
return current->haveValue(txhash, nOut);
}
bool CClaimTrie::haveSupport(const std::string& name, const uint256& txhash, uint32_t nOut) const
{
supportMapNodeType node;
@ -232,6 +231,41 @@ bool CClaimTrie::haveSupport(const std::string& name, const uint256& txhash, uin
return false;
}
bool CClaimTrie::haveClaimInQueueRow(const std::string& name, const uint256& txhash, uint32_t nOut, int nHeight, const std::vector<CValueQueueEntry>& row) const
{
for (std::vector<CValueQueueEntry>::const_iterator itRow = row.begin(); itRow != row.end(); ++itRow)
{
if (itRow->name == name && itRow->val.txhash == txhash && itRow->val.nOut == nOut && itRow->val.nHeight == nHeight)
{
return true;
}
}
return false;
}
bool CClaimTrie::haveClaimInQueue(const std::string& name, const uint256& txhash, uint32_t nOut, int nHeight, int& nValidAtHeight) const
{
std::vector<CValueQueueEntry> row;
if (getQueueRow(nHeight, row))
{
if (haveClaimInQueueRow(name, txhash, nOut, nHeight, row))
{
nValidAtHeight = nHeight;
return true;
}
}
row.clear();
if (getQueueRow(nHeight + DEFAULT_DELAY, row))
{
if (haveClaimInQueueRow(name, txhash, nOut, nHeight, row))
{
nValidAtHeight = nHeight + DEFAULT_DELAY;
return true;
}
}
return false;
}
unsigned int CClaimTrie::getTotalNamesInTrie() const
{
if (empty())
@ -368,9 +402,9 @@ bool CClaimTrie::recursiveCheckConsistency(CClaimTrieNode* node)
return calculatedHash == node->hash;
}
bool CClaimTrie::getQueueRow(int nHeight, std::vector<CValueQueueEntry>& row)
bool CClaimTrie::getQueueRow(int nHeight, std::vector<CValueQueueEntry>& row) const
{
valueQueueType::iterator itQueueRow = dirtyQueueRows.find(nHeight);
valueQueueType::const_iterator itQueueRow = dirtyQueueRows.find(nHeight);
if (itQueueRow != dirtyQueueRows.end())
{
row = itQueueRow->second;

View file

@ -231,12 +231,14 @@ public:
bool supportQueueEmpty() const;
bool expirationQueueEmpty() const;
void setExpirationTime(int t);
bool getQueueRow(int nHeight, std::vector<CValueQueueEntry>& row);
bool getQueueRow(int nHeight, std::vector<CValueQueueEntry>& row) const;
bool getExpirationQueueRow(int nHeight, std::vector<CValueQueueEntry>& row);
bool getSupportNode(std::string name, supportMapNodeType& node);
bool getSupportNode(std::string name, supportMapNodeType& node) const;
bool getSupportQueueRow(int nHeight, std::vector<CSupportValueQueueEntry>& row);
bool haveClaim(const std::string& name, const uint256& txhash, uint32_t nOut) const;
bool haveClaimInQueue(const std::string& name, const uint256& txhash, uint32_t nOut, int nHeight, int& nValidAtHeight) const;
bool haveClaimInQueueRow(const std::string& name, const uint256& txhash, uint32_t nOut, int nHeight, const std::vector<CValueQueueEntry>& row) const;
bool haveSupport(const std::string& name, const uint256& txhash, uint32_t nOut) const;
unsigned int getTotalNamesInTrie() const;
unsigned int getTotalClaimsInTrie() const;

View file

@ -2,6 +2,7 @@
#include "nameclaim.h"
#include "rpcserver.h"
#include "univalue.h"
#include "txmempool.h"
UniValue getclaimtrie(const UniValue& params, bool fHelp)
{
@ -160,3 +161,112 @@ UniValue gettotalvalueofclaims(const UniValue& params, bool fHelp)
return ValueFromAmount(total_amount);
}
UniValue getclaimsfortx(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw std::runtime_error(
"getclaimsfortx\n"
"Return any claims or supports found in a transaction\n"
"Arguments:\n"
"1. \"txid\" (string) the txid of the transaction to check for unspent claims\n"
"Result:\n"
"[\n"
" {\n"
" \"nOut\" (numeric) the index of the claim in the transaction's list out outputs\n"
" \"name\" (string) the name claimed\n"
" \"value\" (string) the value of the claim\n"
" \"depth\" (numeric) the depth of the transaction in the main chain\n"
" \"in claim trie\" (boolean) whether the claim has made it into the trie\n"
" \"is controlling\" (boolean) whether the claim is the current controlling claim for the name\n"
" \"in queue\" (boolean) whether the claim is in a queue waiting to be inserted into the trie\n"
" \"blocks to valid\" (numeric) if in a queue, the number of blocks until it's inserted into the trie\n"
" }\n"
"]\n"
);
LOCK(cs_main);
uint256 hash;
hash.SetHex(params[0].get_str());
UniValue ret(UniValue::VARR);
int op;
std::vector<std::vector<unsigned char> > vvchParams;
CCoinsViewCache view(pcoinsTip);
const CCoins* coin = view.AccessCoins(hash);
std::vector<CTxOut> txouts;
int nHeight = 0;
if (!coin)
{
CTransaction tx;
if (!mempool.lookup(hash, tx))
{
return NullUniValue;
}
else
{
txouts = tx.vout;
}
}
else
{
txouts = coin->vout;
nHeight = coin->nHeight;
}
for (unsigned int i = 0; i < txouts.size(); ++i)
{
if (!txouts[i].IsNull())
{
vvchParams.clear();
const CTxOut& txout = txouts[i];
UniValue o(UniValue::VOBJ);
if (DecodeClaimScript(txout.scriptPubKey, op, vvchParams))
{
o.push_back(Pair("nOut", (int64_t)i));
std::string sName(vvchParams[0].begin(), vvchParams[0].end());
o.push_back(Pair("name", sName));
std::string sValue(vvchParams[1].begin(), vvchParams[1].end());
o.push_back(Pair("value", sValue));
if (nHeight > 0)
{
o.push_back(Pair("depth", chainActive.Height() - nHeight));
bool inClaimTrie = pclaimTrie->haveClaim(sName, hash, i);
o.push_back(Pair("in claim trie", inClaimTrie));
if (inClaimTrie)
{
CNodeValue val;
if (!pclaimTrie->getInfoForName(sName, val))
{
LogPrintf("HaveClaim was true but getInfoForName returned false.");
}
o.push_back(Pair("is controlling", (val.txhash == hash && val.nOut == i)));
}
else
{
int nValidAtHeight;
if (pclaimTrie->haveClaimInQueue(sName, hash, i, coin->nHeight, nValidAtHeight))
{
o.push_back(Pair("in queue", true));
o.push_back(Pair("blocks to valid", nValidAtHeight - chainActive.Height()));
}
else
{
o.push_back(Pair("in queue", false));
}
}
}
else
{
o.push_back(Pair("depth", 0));
o.push_back(Pair("in claim trie", false));
o.push_back(Pair("in queue", false));
}
ret.push_back(o);
}
}
}
return ret;
}

View file

@ -384,6 +384,7 @@ static const CRPCCommand vRPCCommands[] =
{ "claimtrie", "gettotalclaimednames", &gettotalclaimednames, true },
{ "claimtrie", "gettotalclaims", &gettotalclaims, true },
{ "claimtrie", "gettotalvalueofclaims", &gettotalvalueofclaims, true },
{ "claimtrie", "getclaimsfortx", &getclaimsfortx, true },
};
CRPCTable::CRPCTable()

View file

@ -273,6 +273,7 @@ extern UniValue getvalueforname(const UniValue& params, bool fHelp);
extern UniValue gettotalclaimednames(const UniValue& params, bool fHelp);
extern UniValue gettotalclaims(const UniValue& params, bool fHelp);
extern UniValue gettotalvalueofclaims(const UniValue& params, bool fHelp);
extern UniValue getclaimsfortx(const UniValue& params, bool fHelp);
bool StartRPC();