From 6cce052bf71498f03bfc0db8a97dfb4ea5a72bf5 Mon Sep 17 00:00:00 2001 From: kaykurokawa Date: Mon, 28 May 2018 11:43:28 -0700 Subject: [PATCH 1/4] add a data directory section to README, fix util.cpp comment to list the proper lbrycrd default data directories --- README.md | 20 ++++++++++++++++++++ src/util.cpp | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64d31aafe..0d5d57f73 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,26 @@ Run `./lbrycrd-cli getinfo` to check for some basic informations about your LBRY Run `./lbrycrd-cli help` to get a list of all commands that you can run. To get help on specific commands run `./lbrycrd-cli [command_name] help` +### Data directory + +Lbrycrdd will use the below default data directories + +Windows < Vista: C:\Documents and Settings\Username\Application Data\lbrycrd +Windows >= Vista: C:\Users\Username\AppData\Roaming\lbrycrd +Mac: ~/Library/Application Support/lbrycrd +Unix: ~/.lbrycrd + +The data directory contains various things such as your default wallet (wallet.dat), debug logs (debug.log), and blockchain data. You can optionally +create a configuration file lbrycrd.conf in the default data directory which will be used by default when running lbrycrdd. +For a list of configuration parameters run `./lbrycrdd --help`. Below is a sample lbrycrd.conf to enable JSON RPC server on lbrycrdd. + +```rpcuser=lbry +rpcpassword=xyz123456790 +daemon=1 +server=1 +txindex=1 +``` + ## Running from Source Run `./reproducible_build.sh -c -t`. This will build the binaries and put them into the `./src` directory. diff --git a/src/util.cpp b/src/util.cpp index ba4fab1d0..5cc274934 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -455,9 +455,9 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread) boost::filesystem::path GetDefaultDataDir() { namespace fs = boost::filesystem; - // Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin - // Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin - // Mac: ~/Library/Application Support/Bitcoin + // Windows < Vista: C:\Documents and Settings\Username\Application Data\lbrycrd + // Windows >= Vista: C:\Users\Username\AppData\Roaming\lbrycrd + // Mac: ~/Library/Application Support/lbrycrd // Unix: ~/.lbrycrd #ifdef WIN32 // Windows -- 2.45.3 From 4badde8595ba8b37235e2c615d469da70659888b Mon Sep 17 00:00:00 2001 From: lbrynaut Date: Mon, 21 May 2018 15:54:09 -0500 Subject: [PATCH 2/4] Add support information to getclaimbyid rpc --- src/claimtrie.cpp | 52 ++++++++++++++++++++++++++----------------- src/claimtrie.h | 2 ++ src/rpc/claimtrie.cpp | 27 ++++++++++++++++++++-- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/src/claimtrie.cpp b/src/claimtrie.cpp index c7ebcc6a4..743bda4ed 100644 --- a/src/claimtrie.cpp +++ b/src/claimtrie.cpp @@ -526,31 +526,41 @@ claimsForNameType CClaimTrie::getClaimsForName(const std::string& name) const return allClaims; } -//return effective amount form claim, retuns 0 if claim is not found +//return effective amount from claim, retuns 0 if claim is not found CAmount CClaimTrie::getEffectiveAmountForClaim(const std::string& name, uint160 claimId) const { - claimsForNameType claims = getClaimsForName(name); - CAmount effectiveAmount = 0; - bool claim_found = false; - for (std::vector::iterator it=claims.claims.begin(); it!=claims.claims.end(); ++it) - { - if (it->claimId == claimId && it->nValidAtHeight < nCurrentHeight) - { - effectiveAmount += it->nAmount; - claim_found = true; - break; - } - } - if (!claim_found) - return effectiveAmount; + std::vector supports; + return getEffectiveAmountForClaimWithSupports(name, claimId, supports); +} - for (std::vector::iterator it=claims.supports.begin(); it!=claims.supports.end(); ++it) - { - if (it->supportedClaimId == claimId && it->nValidAtHeight < nCurrentHeight) - effectiveAmount += it->nAmount; - } - return effectiveAmount; +//return effective amount from claim and the supports used as inputs, retuns 0 if claim is not found +CAmount CClaimTrie::getEffectiveAmountForClaimWithSupports(const std::string& name, uint160 claimId, + std::vector& supports) const +{ + claimsForNameType claims = getClaimsForName(name); + CAmount effectiveAmount = 0; + bool claim_found = false; + for (std::vector::iterator it=claims.claims.begin(); it!=claims.claims.end(); ++it) + { + if (it->claimId == claimId && it->nValidAtHeight < nCurrentHeight) + { + effectiveAmount += it->nAmount; + claim_found = true; + break; + } + } + if (!claim_found) + return effectiveAmount; + for (std::vector::iterator it=claims.supports.begin(); it!=claims.supports.end(); ++it) + { + if (it->supportedClaimId == claimId && it->nValidAtHeight < nCurrentHeight) + { + effectiveAmount += it->nAmount; + supports.push_back(*it); + } + } + return effectiveAmount; } bool CClaimTrie::checkConsistency() const diff --git a/src/claimtrie.h b/src/claimtrie.h index b3ec6e6c0..b7311a87a 100644 --- a/src/claimtrie.h +++ b/src/claimtrie.h @@ -321,6 +321,8 @@ public: claimsForNameType getClaimsForName(const std::string& name) const; CAmount getEffectiveAmountForClaim(const std::string& name, uint160 claimId) const; + CAmount getEffectiveAmountForClaimWithSupports(const std::string& name, uint160 claimId, + std::vector& supports) const; bool queueEmpty() const; bool supportEmpty() const; diff --git a/src/rpc/claimtrie.cpp b/src/rpc/claimtrie.cpp index e6f0fc5eb..db9a261fe 100644 --- a/src/rpc/claimtrie.cpp +++ b/src/rpc/claimtrie.cpp @@ -367,6 +367,14 @@ UniValue getclaimbyid(const UniValue& params, bool fHelp) " \"amount\" (numeric) txout value\n" " \"effective amount\" (numeric) txout amount plus amount from all supports associated with the claim\n" " \"height\" (numeric) the height of the block in which this claim transaction is located\n" + " \"supports\" (array of object) supports for this claim\n" + " [\n" + " \"txid\" (string) the txid of the support\n" + " \"n\" (numeric) the index of the support in the transaction's list of outputs\n" + " \"height\" (numeric) the height at which the support was included in the blockchain\n" + " \"valid at height\" (numeric) the height at which the support became/becomes valid\n" + " \"amount\" (numeric) the amount of the support\n" + " ]\n" "}\n" ); @@ -379,6 +387,10 @@ UniValue getclaimbyid(const UniValue& params, bool fHelp) pclaimTrie->getClaimById(claimId, name, claimValue); if (claimValue.claimId == claimId) { + std::vector supports; + CAmount effectiveAmount = pclaimTrie->getEffectiveAmountForClaimWithSupports( + name, claimValue.claimId, supports); + std::string sValue; getValueForClaim(claimValue.outPoint, sValue); claim.push_back(Pair("name", name)); @@ -387,9 +399,20 @@ UniValue getclaimbyid(const UniValue& params, bool fHelp) claim.push_back(Pair("txid", claimValue.outPoint.hash.GetHex())); claim.push_back(Pair("n", (int) claimValue.outPoint.n)); claim.push_back(Pair("amount", claimValue.nAmount)); - claim.push_back(Pair("effective amount", - pclaimTrie->getEffectiveAmountForClaim(name, claimValue.claimId))); + claim.push_back(Pair("effective amount", effectiveAmount)); + UniValue supportList(UniValue::VARR); + BOOST_FOREACH(const CSupportValue& support, supports) { + UniValue supportEntry(UniValue::VOBJ); + supportEntry.push_back(Pair("txid", support.outPoint.hash.GetHex())); + supportEntry.push_back(Pair("n", (int)support.outPoint.n)); + supportEntry.push_back(Pair("height", support.nHeight)); + supportEntry.push_back(Pair("valid at height", support.nValidAtHeight)); + supportEntry.push_back(Pair("amount", support.nAmount)); + supportList.push_back(supportEntry); + } + claim.push_back(Pair("supports", supportList)); claim.push_back(Pair("height", claimValue.nHeight)); + claim.push_back(Pair("valid at height", claimValue.nValidAtHeight)); } return claim; } -- 2.45.3 From 995b5a6666f0530de3f9259cb889fefb1a7483f1 Mon Sep 17 00:00:00 2001 From: lbrynaut Date: Wed, 30 May 2018 14:02:05 -0400 Subject: [PATCH 3/4] Update doc string for claim's valid_at_height parameter --- src/rpc/claimtrie.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/claimtrie.cpp b/src/rpc/claimtrie.cpp index db9a261fe..304a104ec 100644 --- a/src/rpc/claimtrie.cpp +++ b/src/rpc/claimtrie.cpp @@ -368,11 +368,12 @@ UniValue getclaimbyid(const UniValue& params, bool fHelp) " \"effective amount\" (numeric) txout amount plus amount from all supports associated with the claim\n" " \"height\" (numeric) the height of the block in which this claim transaction is located\n" " \"supports\" (array of object) supports for this claim\n" + " \"valid at height\" (numeric) the height at which the claim is valid\n" " [\n" " \"txid\" (string) the txid of the support\n" " \"n\" (numeric) the index of the support in the transaction's list of outputs\n" " \"height\" (numeric) the height at which the support was included in the blockchain\n" - " \"valid at height\" (numeric) the height at which the support became/becomes valid\n" + " \"valid at height\" (numeric) the height at which the support is valid\n" " \"amount\" (numeric) the amount of the support\n" " ]\n" "}\n" -- 2.45.3 From da3c52631cd37ec99855d32dbcd96ce172f1c9d1 Mon Sep 17 00:00:00 2001 From: kay kurokawa Date: Mon, 4 Jun 2018 14:42:10 -0400 Subject: [PATCH 4/4] add note about c++ version, adjust formatting in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64d31aafe..530d10078 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ If you encounter any errors, please check `doc/build-*.md` for further instructi Contributions to this project are welcome, encouraged, and compensated. For more details, see [lbry.io/faq/contributing](https://lbry.io/faq/contributing) +The codebase is in C++03, C++11 is currently not supported but we will be migrating to it in the near future. Recommended GCC version is 4.8 or greater. + The `master` branch is regularly built and tested, but is not guaranteed to be completely stable. [Releases](https://github.com/lbryio/lbrycrd/releases) are created regularly to indicate new official, stable release versions. @@ -39,9 +41,7 @@ regularly to indicate new official, stable release versions. Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people -lots of money. - -Developers are strongly encouraged to write [unit tests](/doc/unit-tests.md) for new code, and to +lots of money. Developers are strongly encouraged to write [unit tests](/doc/unit-tests.md) for new code, and to submit new unit tests for old code. Unit tests can be compiled and run (assuming they weren't disabled in configure) with: `make check` -- 2.45.3