diff --git a/README.md b/README.md index 0d5d57f73..530d10078 100644 --- a/README.md +++ b/README.md @@ -22,26 +22,6 @@ 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. @@ -52,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. @@ -59,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` diff --git a/src/claimtrie.cpp b/src/claimtrie.cpp index 743bda4ed..c7ebcc6a4 100644 --- a/src/claimtrie.cpp +++ b/src/claimtrie.cpp @@ -526,41 +526,31 @@ claimsForNameType CClaimTrie::getClaimsForName(const std::string& name) const return allClaims; } -//return effective amount from claim, retuns 0 if claim is not found +//return effective amount form claim, retuns 0 if claim is not found CAmount CClaimTrie::getEffectiveAmountForClaim(const std::string& name, uint160 claimId) const { - std::vector supports; - return getEffectiveAmountForClaimWithSupports(name, claimId, supports); -} + 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; -//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; + } + 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 b7311a87a..b3ec6e6c0 100644 --- a/src/claimtrie.h +++ b/src/claimtrie.h @@ -321,8 +321,6 @@ 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 304a104ec..e6f0fc5eb 100644 --- a/src/rpc/claimtrie.cpp +++ b/src/rpc/claimtrie.cpp @@ -367,15 +367,6 @@ 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" - " \"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 is valid\n" - " \"amount\" (numeric) the amount of the support\n" - " ]\n" "}\n" ); @@ -388,10 +379,6 @@ 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)); @@ -400,20 +387,9 @@ 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", 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("effective amount", + pclaimTrie->getEffectiveAmountForClaim(name, claimValue.claimId))); claim.push_back(Pair("height", claimValue.nHeight)); - claim.push_back(Pair("valid at height", claimValue.nValidAtHeight)); } return claim; } diff --git a/src/util.cpp b/src/util.cpp index 5cc274934..ba4fab1d0 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\lbrycrd - // Windows >= Vista: C:\Users\Username\AppData\Roaming\lbrycrd - // Mac: ~/Library/Application Support/lbrycrd + // Windows < Vista: C:\Documents and Settings\Username\Application Data\Bitcoin + // Windows >= Vista: C:\Users\Username\AppData\Roaming\Bitcoin + // Mac: ~/Library/Application Support/Bitcoin // Unix: ~/.lbrycrd #ifdef WIN32 // Windows