show depth, whether spent, and whether in ncc trie for listnameclaims

This commit is contained in:
Jimmy Kiselak 2015-03-19 17:16:35 -04:00
parent c8834c5551
commit 7813f3157b
3 changed files with 26 additions and 1 deletions

View file

@ -87,6 +87,14 @@ bool CNCCTrieNode::getBestValue(CNodeValue& value) const
}
}
bool CNCCTrieNode::haveValue(const uint256& txhash, uint32_t nOut) const
{
for (std::vector<CNodeValue>::const_iterator itval = values.begin(); itval != values.end(); ++itval)
if (itval->txhash == txhash && itval->nOut == nOut)
return true;
return false;
}
uint256 CNCCTrie::getMerkleHash()
{
return root.hash;
@ -102,6 +110,19 @@ bool CNCCTrie::queueEmpty() const
return valueQueue.empty();
}
bool CNCCTrie::haveClaim(const std::string& name, const uint256& txhash, uint32_t nOut) const
{
const CNCCTrieNode* current = &root;
for (std::string::const_iterator itname = name.begin(); itname != name.end(); ++itname)
{
nodeMapType::const_iterator itchildren = current->children.find(*itname);
if (itchildren == current->children.end())
return false;
current = itchildren->second;
}
return current->haveValue(txhash, nOut);
}
bool CNCCTrie::recursiveDumpToJSON(const std::string& name, const CNCCTrieNode* current, json_spirit::Array& ret) const
{
using namespace json_spirit;

View file

@ -88,7 +88,7 @@ public:
bool removeValue(uint256& txhash, uint32_t nOut, CNodeValue& val, bool * fChanged = NULL);
bool getBestValue(CNodeValue& val) const;
bool empty() const {return children.empty() && values.empty();}
bool haveValue(const uint256& txhash, uint32_t nOut) const;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
@ -159,6 +159,7 @@ public:
bool getInfoForName(const std::string& name, CNodeValue& val) const;
int nCurrentHeight;
bool queueEmpty() const;
bool haveClaim(const std::string& name, const uint256& txhash, uint32_t nOut) const;
friend class CNCCTrieCache;
private:
bool update(nodeCacheType& cache, hashMapType& hashes, const uint256& hashBlock, valueQueueType& queueCache, int nNewHeight);

View file

@ -610,6 +610,9 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept
entry.push_back(Pair("amount", ValueFromAmount(s.amount)));
entry.push_back(Pair("vout", s.vout));
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));
entry.push_back(Pair("is spent", pwalletMain->IsSpent(wtx.GetHash(), s.vout)));
entry.push_back(Pair("is in ncc trie", pnccTrie->haveClaim(sName, wtx.GetHash(), s.vout)));
ret.push_back(entry);
}
}