change user-facing mention of ncc to lbrycrd/name, and move all UniValue out of ncctrie.cpp
This commit is contained in:
parent
3d7b9221b5
commit
d3df7747d7
9 changed files with 48 additions and 42 deletions
|
@ -31,7 +31,7 @@ using namespace std;
|
||||||
class CMainParams : public CChainParams {
|
class CMainParams : public CChainParams {
|
||||||
public:
|
public:
|
||||||
CMainParams() {
|
CMainParams() {
|
||||||
strNetworkID = "newcc";
|
strNetworkID = "lbrycrd";
|
||||||
consensus.nSubsidyHalvingInterval = 2100000;
|
consensus.nSubsidyHalvingInterval = 2100000;
|
||||||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||||
consensus.nMajorityRejectBlockOutdated = 950;
|
consensus.nMajorityRejectBlockOutdated = 950;
|
||||||
|
|
|
@ -279,36 +279,26 @@ CAmount CNCCTrie::getTotalValueOfClaimsRecursive(const CNCCTrieNode* current, bo
|
||||||
return value_in_subtrie;
|
return value_in_subtrie;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNCCTrie::recursiveDumpToJSON(const std::string& name, const CNCCTrieNode* current, UniValue& ret) const
|
bool CNCCTrie::recursiveFlattenTrie(const std::string& name, const CNCCTrieNode* current, std::vector<namedNodeType>& nodes) const
|
||||||
{
|
{
|
||||||
UniValue objNode(UniValue::VOBJ);
|
namedNodeType node(name, *current);
|
||||||
objNode.push_back(Pair("name", name));
|
nodes.push_back(node);
|
||||||
objNode.push_back(Pair("hash", current->hash.GetHex()));
|
|
||||||
CNodeValue val;
|
|
||||||
if (current->getBestValue(val))
|
|
||||||
{
|
|
||||||
objNode.push_back(Pair("txid", val.txhash.GetHex()));
|
|
||||||
objNode.push_back(Pair("n", (int)val.nOut));
|
|
||||||
objNode.push_back(Pair("value", val.nAmount));
|
|
||||||
objNode.push_back(Pair("height", val.nHeight));
|
|
||||||
}
|
|
||||||
ret.push_back(objNode);
|
|
||||||
for (nodeMapType::const_iterator it = current->children.begin(); it != current->children.end(); ++it)
|
for (nodeMapType::const_iterator it = current->children.begin(); it != current->children.end(); ++it)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << name << it->first;
|
ss << name << it->first;
|
||||||
if (!recursiveDumpToJSON(ss.str(), it->second, ret))
|
if (!recursiveFlattenTrie(ss.str(), it->second, nodes))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue CNCCTrie::dumpToJSON() const
|
std::vector<namedNodeType> CNCCTrie::flattenTrie() const
|
||||||
{
|
{
|
||||||
UniValue ret(UniValue::VARR);
|
std::vector<namedNodeType> nodes;
|
||||||
if (!recursiveDumpToJSON("", &root, ret))
|
if (!recursiveFlattenTrie("", &root, nodes))
|
||||||
LogPrintf("%s: Something went wrong dumping to JSON", __func__);
|
LogPrintf("%s: Something went wrong flattening the trie", __func__);
|
||||||
return ret;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNCCTrie::getInfoForName(const std::string& name, CNodeValue& val) const
|
bool CNCCTrie::getInfoForName(const std::string& name, CNodeValue& val) const
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "univalue/univalue.h"
|
|
||||||
|
|
||||||
#define DEFAULT_DELAY 100
|
#define DEFAULT_DELAY 100
|
||||||
|
|
||||||
|
@ -73,6 +72,8 @@ class CNCCTrie;
|
||||||
|
|
||||||
typedef std::map<unsigned char, CNCCTrieNode*> nodeMapType;
|
typedef std::map<unsigned char, CNCCTrieNode*> nodeMapType;
|
||||||
|
|
||||||
|
typedef std::pair<std::string, CNCCTrieNode> namedNodeType;
|
||||||
|
|
||||||
class CNCCTrieNode
|
class CNCCTrieNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -155,7 +156,7 @@ public:
|
||||||
bool checkConsistency();
|
bool checkConsistency();
|
||||||
bool WriteToDisk();
|
bool WriteToDisk();
|
||||||
bool ReadFromDisk(bool check = false);
|
bool ReadFromDisk(bool check = false);
|
||||||
UniValue dumpToJSON() const;
|
std::vector<namedNodeType> flattenTrie() const;
|
||||||
bool getInfoForName(const std::string& name, CNodeValue& val) const;
|
bool getInfoForName(const std::string& name, CNodeValue& val) const;
|
||||||
int nCurrentHeight;
|
int nCurrentHeight;
|
||||||
bool queueEmpty() const;
|
bool queueEmpty() const;
|
||||||
|
@ -180,7 +181,7 @@ private:
|
||||||
unsigned int getTotalNamesRecursive(const CNCCTrieNode* current) const;
|
unsigned int getTotalNamesRecursive(const CNCCTrieNode* current) const;
|
||||||
unsigned int getTotalClaimsRecursive(const CNCCTrieNode* current) const;
|
unsigned int getTotalClaimsRecursive(const CNCCTrieNode* current) const;
|
||||||
CAmount getTotalValueOfClaimsRecursive(const CNCCTrieNode* current, bool fControllingOnly) const;
|
CAmount getTotalValueOfClaimsRecursive(const CNCCTrieNode* current, bool fControllingOnly) const;
|
||||||
bool recursiveDumpToJSON(const std::string& name, const CNCCTrieNode* current, UniValue& ret) const;
|
bool recursiveFlattenTrie(const std::string& name, const CNCCTrieNode* current, std::vector<namedNodeType>& nodes) const;
|
||||||
CNCCTrieNode root;
|
CNCCTrieNode root;
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
valueQueueType dirtyQueueRows;
|
valueQueueType dirtyQueueRows;
|
||||||
|
|
|
@ -17,7 +17,7 @@ static const struct {
|
||||||
const char *titleAddText;
|
const char *titleAddText;
|
||||||
} network_styles[] = {
|
} network_styles[] = {
|
||||||
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
|
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
|
||||||
{"newcc", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
|
{"lbrycrd", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
|
||||||
{"test", QAPP_APP_NAME_TESTNET, 70, 30, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")},
|
{"test", QAPP_APP_NAME_TESTNET, 70, 30, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")},
|
||||||
{"regtest", QAPP_APP_NAME_TESTNET, 160, 30, "[regtest]"}
|
{"regtest", QAPP_APP_NAME_TESTNET, 160, 30, "[regtest]"}
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
#include "rpcserver.h"
|
#include "rpcserver.h"
|
||||||
#include "univalue/univalue.h"
|
#include "univalue/univalue.h"
|
||||||
|
|
||||||
UniValue getncctrie(const UniValue& params, bool fHelp)
|
UniValue getnametrie(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() > 0)
|
if (fHelp || params.size() > 0)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"getncctrie\n"
|
"getnametrie\n"
|
||||||
"Return the entire NCC trie.\n"
|
"Return the entire name trie.\n"
|
||||||
"Arguments:\n"
|
"Arguments:\n"
|
||||||
"None\n"
|
"None\n"
|
||||||
"Result: \n"
|
"Result: \n"
|
||||||
|
@ -23,9 +23,24 @@ UniValue getncctrie(const UniValue& params, bool fHelp)
|
||||||
);
|
);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
UniValue ret = pnccTrie->dumpToJSON();
|
std::vector<namedNodeType> nodes = pnccTrie->flattenTrie();
|
||||||
|
for (std::vector<namedNodeType>::iterator it = nodes.begin(); it != nodes.end(); ++it)
|
||||||
|
{
|
||||||
|
UniValue node(UniValue::VOBJ);
|
||||||
|
node.push_back(Pair("name", it->first));
|
||||||
|
node.push_back(Pair("hash", it->second.hash.GetHex()));
|
||||||
|
CNodeValue val;
|
||||||
|
if (it->second.getBestValue(val))
|
||||||
|
{
|
||||||
|
node.push_back(Pair("txid", val.txhash.GetHex()));
|
||||||
|
node.push_back(Pair("n", (int)val.nOut));
|
||||||
|
node.push_back(Pair("value", ValueFromAmount(val.nAmount)));
|
||||||
|
node.push_back(Pair("height", val.nHeight));
|
||||||
|
}
|
||||||
|
ret.push_back(node);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,12 +380,12 @@ static const CRPCCommand vRPCCommands[] =
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
/* NCC trie */
|
/* NCC trie */
|
||||||
{ "ncctrie", "getncctrie", &getncctrie, true },
|
{ "nametrie", "getnametrie", &getnametrie, true },
|
||||||
{ "ncctrie", "gettxinfoforname", &gettxinfoforname, true },
|
{ "nametrie", "gettxinfoforname", &gettxinfoforname, true },
|
||||||
{ "ncctrie", "getvalueforname", &getvalueforname, true },
|
{ "nametrie", "getvalueforname", &getvalueforname, true },
|
||||||
{ "ncctrie", "gettotalclaimednames", &gettotalclaimednames, true },
|
{ "nametrie", "gettotalclaimednames", &gettotalclaimednames, true },
|
||||||
{ "ncctrie", "gettotalclaims", &gettotalclaims, true },
|
{ "nametrie", "gettotalclaims", &gettotalclaims, true },
|
||||||
{ "ncctrie", "gettotalvalueofclaims", &gettotalvalueofclaims, true },
|
{ "nametrie", "gettotalvalueofclaims", &gettotalvalueofclaims, true },
|
||||||
};
|
};
|
||||||
|
|
||||||
CRPCTable::CRPCTable()
|
CRPCTable::CRPCTable()
|
||||||
|
|
|
@ -241,7 +241,7 @@ extern UniValue getchaintips(const UniValue& params, bool fHelp);
|
||||||
extern UniValue invalidateblock(const UniValue& params, bool fHelp);
|
extern UniValue invalidateblock(const UniValue& params, bool fHelp);
|
||||||
extern UniValue reconsiderblock(const UniValue& params, bool fHelp);
|
extern UniValue reconsiderblock(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern UniValue getncctrie(const UniValue& params, bool fHelp); // in rpcncctrie.cpp
|
extern UniValue getnametrie(const UniValue& params, bool fHelp); // in rpcncctrie.cpp
|
||||||
extern UniValue gettxinfoforname(const UniValue& params, bool fHelp);
|
extern UniValue gettxinfoforname(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getvalueforname(const UniValue& params, bool fHelp);
|
extern UniValue getvalueforname(const UniValue& params, bool fHelp);
|
||||||
extern UniValue gettotalclaimednames(const UniValue& params, bool fHelp);
|
extern UniValue gettotalclaimednames(const UniValue& params, bool fHelp);
|
||||||
|
|
|
@ -416,7 +416,7 @@ boost::filesystem::path GetDefaultDataDir()
|
||||||
return pathRet / "Bitcoin";
|
return pathRet / "Bitcoin";
|
||||||
#else
|
#else
|
||||||
// Unix
|
// Unix
|
||||||
return pathRet / ".newcc";
|
return pathRet / ".lbrycrd";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ UniValue claimname(const UniValue& params, bool fHelp)
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"name\" (string, required) The name to be assigned the value.\n"
|
"1. \"name\" (string, required) The name to be assigned the value.\n"
|
||||||
"2. \"value\" (string, required) The value to assign to the name.\n"
|
"2. \"value\" (string, required) The value to assign to the name.\n"
|
||||||
"3. \"amount\" (numeric, required) The amount in ncc to send. eg 0.1\n"
|
"3. \"amount\" (numeric, required) The amount in LBRYcrd to send. eg 0.1\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"\"transactionid\" (string) The transaction id.\n"
|
"\"transactionid\" (string) The transaction id.\n"
|
||||||
);
|
);
|
||||||
|
@ -484,7 +484,7 @@ UniValue updatename(const UniValue& params, bool fHelp)
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"txid\" (string, required) The transaction containing the unspent txout which should be spent.\n"
|
"1. \"txid\" (string, required) The transaction containing the unspent txout which should be spent.\n"
|
||||||
"2. \"value\" (string, required) The value to assign to the name.\n"
|
"2. \"value\" (string, required) The value to assign to the name.\n"
|
||||||
"3. \"amount\" (numeric, required) The amount in ncc to send. eg 0.1\n"
|
"3. \"amount\" (numeric, required) The amount in LBRYcrd to send. eg 0.1\n"
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"\"transactionid\" (string) The new transaction id.\n"
|
"\"transactionid\" (string) The new transaction id.\n"
|
||||||
);
|
);
|
||||||
|
@ -663,7 +663,7 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept
|
||||||
entry.push_back(Pair("txid", wtx.GetHash().ToString()));
|
entry.push_back(Pair("txid", wtx.GetHash().ToString()));
|
||||||
entry.push_back(Pair("account", strSentAccount));
|
entry.push_back(Pair("account", strSentAccount));
|
||||||
MaybePushAddress(entry, s.destination);
|
MaybePushAddress(entry, s.destination);
|
||||||
entry.push_back(Pair("category", "ncc"));
|
entry.push_back(Pair("category", "name"));
|
||||||
entry.push_back(Pair("amount", ValueFromAmount(s.amount)));
|
entry.push_back(Pair("amount", ValueFromAmount(s.amount)));
|
||||||
entry.push_back(Pair("vout", s.vout));
|
entry.push_back(Pair("vout", s.vout));
|
||||||
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||||
|
@ -688,7 +688,7 @@ void ListNameClaims(const CWalletTx& wtx, const string& strAccount, int nMinDept
|
||||||
}
|
}
|
||||||
entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));
|
entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));
|
||||||
entry.push_back(Pair("is spent", pwalletMain->IsSpent(wtx.GetHash(), s.vout)));
|
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)));
|
entry.push_back(Pair("is in name trie", pnccTrie->haveClaim(sName, wtx.GetHash(), s.vout)));
|
||||||
ret.push_back(entry);
|
ret.push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -717,7 +717,7 @@ UniValue listnameclaims(const UniValue& params, bool fHelp)
|
||||||
" \"account\":\"accountname\", (string) The account name associated with the transaction. \n"
|
" \"account\":\"accountname\", (string) The account name associated with the transaction. \n"
|
||||||
" It will be \"\" for the default account.\n"
|
" It will be \"\" for the default account.\n"
|
||||||
" \"address\":\"bitcoinaddress\", (string) The bitcoin address of the transaction.\n"
|
" \"address\":\"bitcoinaddress\", (string) The bitcoin address of the transaction.\n"
|
||||||
" \"category\":\"ncc\" (string) Always ncc\n"
|
" \"category\":\"name\" (string) Always name\n"
|
||||||
" \"amount\": x.xxx, (numeric) The amount in btc.\n"
|
" \"amount\": x.xxx, (numeric) The amount in btc.\n"
|
||||||
" \"vout\": n, (numeric) The vout value\n"
|
" \"vout\": n, (numeric) The vout value\n"
|
||||||
" \"fee\": x.xxx, (numeric) The amount of the fee in btc.\n"
|
" \"fee\": x.xxx, (numeric) The amount of the fee in btc.\n"
|
||||||
|
|
Loading…
Reference in a new issue