From 2a1a4ef9c13e3389165566f79a0d5b057a1a0581 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Tue, 7 May 2019 14:10:12 -0600 Subject: [PATCH] pulled in a few minor keepers from the other rebase branch --- CMakeLists.txt | 11 +++++------ README.md | 1 - configure.ac | 8 +++++--- src/bitcoin-cli-res.rc | 10 +++++----- src/bitcoin-cli.cpp | 4 ++-- src/bitcoin-tx-res.rc | 10 +++++----- src/bitcoind-res.rc | 10 +++++----- src/bitcoind.cpp | 6 +++--- src/claimtrie.cpp | 5 ----- src/leveldb/port/port_posix.cc | 2 +- src/leveldb/util/logging.cc | 2 +- src/test/claimtriebranching_tests.cpp | 4 ++-- src/test/claimtriecache_tests.cpp | 4 ++-- src/validation.cpp | 6 ------ 14 files changed, 36 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90d03e7ea..52a2c7d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,13 +7,15 @@ if(EXISTS "build/boost") set(BOOST_ROOT "build/boost" CACHE PATH "Boost library path") set(Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost") endif() -find_package(Boost REQUIRED COMPONENTS filesystem program_options thread chrono locale) +find_package(Boost REQUIRED COMPONENTS filesystem thread chrono locale) file(GLOB sources src/*.h src/*.cpp src/wallet/*.h src/wallet/*.cpp src/support/*.h src/support/*.cpp src/support/allocators/*.h src/script/*.h src/script/*.cpp + src/index/*.h src/index/*.cpp + src/interfaces/*.h src/interfaces/*.cpp src/rpc/*.h src/rpc/*.cpp src/primitives/*.h src/primitives/*.cpp src/policy/*.h src/policy/*.cpp @@ -50,8 +52,5 @@ add_executable(lbrycrd-tx src/bitcoin-tx.cpp ${sources}) add_executable(lbrycrdd src/bitcoind.cpp ${sources}) file(GLOB tests src/test/*.cpp) -foreach(test ${tests}) - get_filename_component(filename ${test} NAME_WE) - add_executable(${filename} ${test} ${sources}) - target_include_directories(${filename} PRIVATE src/test) -endforeach(test) +add_executable(test_lbrycrd ${tests} ${sources}) +target_include_directories(test_lbrycrd PRIVATE src/test) \ No newline at end of file diff --git a/README.md b/README.md index 1a38dbf17..9a02e0a05 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ 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. We follow the same coding guidelines as documented by Bitcoin Core, see [here](/doc/developer-notes.md). To run an automated code formatting check, try: `git diff -U0 master -- '*.h' '*.cpp' | ./contrib/devtools/clang-format-diff.py -p1`. This will check any commits not on master for proper code formatting. We try to avoid altering parts of the code that is inherited from Bitcoin Core unless absolutely necessary. This will make it easier to merge changes from Bitcoin Core. If commits are expected not to be merged upstream (i.e. we broke up a commit from Bitcoin Core in order to use a single feature in it), the commit message must contain the string "NOT FOR UPSTREAM MERGE". diff --git a/configure.ac b/configure.ac index d9c6ade52..b59df92c3 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2019) define(_COPYRIGHT_HOLDERS,[The %s developers]) define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[LBRYcrd Core]]) -AC_INIT([LBRYcrd Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/bitcoin/bitcoin/issues],[bitcoin],[https://bitcoincore.org/]) +AC_INIT([LBRYcrd Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/lbryio/lbrycrd/issues],[lbrycrd],[https://lbry.com/]) AC_CONFIG_SRCDIR([src/validation.cpp]) AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) AC_CONFIG_AUX_DIR([build-aux]) @@ -646,7 +646,9 @@ if test x$ac_cv_sys_large_files != x && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" fi -AX_CHECK_LINK_FLAG([[-static-libstdc++]], [LDFLAGS="$LDFLAGS -static-libstdc++"]) +if test x$enable_static != x; then + AX_CHECK_LINK_FLAG([[-static-libstdc++]], [LDFLAGS="$LDFLAGS -static-libstdc++"]) +fi AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"]) AX_GCC_FUNC_ATTRIBUTE([visibility]) @@ -1333,7 +1335,7 @@ fi AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) -AC_MSG_CHECKING([whether to build test_bitcoin]) +AC_MSG_CHECKING([whether to build test_lbrycrd]) if test x$use_tests = xyes; then AC_MSG_RESULT([yes]) BUILD_TEST="yes" diff --git a/src/bitcoin-cli-res.rc b/src/bitcoin-cli-res.rc index 58f8f1e8a..00132b9d8 100644 --- a/src/bitcoin-cli-res.rc +++ b/src/bitcoin-cli-res.rc @@ -16,14 +16,14 @@ BEGIN BEGIN BLOCK "040904E4" // U.S. English - multilingual (hex) BEGIN - VALUE "CompanyName", "Bitcoin" - VALUE "FileDescription", "bitcoin-cli (JSON-RPC client for " PACKAGE_NAME ")" + VALUE "CompanyName", "LBRY" + VALUE "FileDescription", "lbrycrd-cli (JSON-RPC client for " PACKAGE_NAME ")" VALUE "FileVersion", VER_FILEVERSION_STR - VALUE "InternalName", "bitcoin-cli" + VALUE "InternalName", "lbrycrd-cli" VALUE "LegalCopyright", COPYRIGHT_STR VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." - VALUE "OriginalFilename", "bitcoin-cli.exe" - VALUE "ProductName", "bitcoin-cli" + VALUE "OriginalFilename", "lbrycrd-cli.exe" + VALUE "ProductName", "lbrycrd-cli" VALUE "ProductVersion", VER_PRODUCTVERSION_STR END END diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 2684399cf..b7dc834af 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -48,7 +48,7 @@ static void SetupCliArgs() gArgs.AddArg("-rpcport=", strprintf("Connect to JSON-RPC on (default: %u or testnet: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()), false, OptionsCategory::OPTIONS); gArgs.AddArg("-rpcuser=", "Username for JSON-RPC connections", false, OptionsCategory::OPTIONS); gArgs.AddArg("-rpcwait", "Wait for RPC server to start", false, OptionsCategory::OPTIONS); - gArgs.AddArg("-rpcwallet=", "Send RPC for non-default wallet on RPC server (needs to exactly match corresponding -wallet option passed to bitcoind)", false, OptionsCategory::OPTIONS); + gArgs.AddArg("-rpcwallet=", "Send RPC for non-default wallet on RPC server (needs to exactly match corresponding -wallet option passed to lbrycrdd)", false, OptionsCategory::OPTIONS); gArgs.AddArg("-stdin", "Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases). When combined with -stdinrpcpass, the first line from standard input is used for the RPC password.", false, OptionsCategory::OPTIONS); gArgs.AddArg("-stdinrpcpass", "Read RPC password from standard input as a single line. When combined with -stdin, the first line from standard input is used for the RPC password.", false, OptionsCategory::OPTIONS); @@ -379,7 +379,7 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co if (response.error != -1) { responseErrorMessage = strprintf(" (error code %d - \"%s\")", response.error, http_errorstring(response.error)); } - throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\nMake sure the bitcoind server is running and that you are connecting to the correct RPC port.", host, port, responseErrorMessage)); + throw CConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\nMake sure the lbrycrdd server is running and that you are connecting to the correct RPC port.", host, port, responseErrorMessage)); } else if (response.status == HTTP_UNAUTHORIZED) { if (failedToGetAuthCookie) { throw std::runtime_error(strprintf( diff --git a/src/bitcoin-tx-res.rc b/src/bitcoin-tx-res.rc index 3e49b820b..a99ee5a95 100644 --- a/src/bitcoin-tx-res.rc +++ b/src/bitcoin-tx-res.rc @@ -16,14 +16,14 @@ BEGIN BEGIN BLOCK "040904E4" // U.S. English - multilingual (hex) BEGIN - VALUE "CompanyName", "Bitcoin" - VALUE "FileDescription", "bitcoin-tx (CLI Bitcoin transaction editor utility)" + VALUE "CompanyName", "LBRY" + VALUE "FileDescription", "lbrycrd-tx (CLI LBRYcrd transaction editor utility)" VALUE "FileVersion", VER_FILEVERSION_STR - VALUE "InternalName", "bitcoin-tx" + VALUE "InternalName", "lbrycrd-tx" VALUE "LegalCopyright", COPYRIGHT_STR VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." - VALUE "OriginalFilename", "bitcoin-tx.exe" - VALUE "ProductName", "bitcoin-tx" + VALUE "OriginalFilename", "lbrycrd-tx.exe" + VALUE "ProductName", "lbrycrd-tx" VALUE "ProductVersion", VER_PRODUCTVERSION_STR END END diff --git a/src/bitcoind-res.rc b/src/bitcoind-res.rc index 3a64acd5d..f2f8ec04d 100644 --- a/src/bitcoind-res.rc +++ b/src/bitcoind-res.rc @@ -16,14 +16,14 @@ BEGIN BEGIN BLOCK "040904E4" // U.S. English - multilingual (hex) BEGIN - VALUE "CompanyName", "Bitcoin" - VALUE "FileDescription", "bitcoind (Bitcoin node with a JSON-RPC server)" + VALUE "CompanyName", "LBRY" + VALUE "FileDescription", "lbrycrdd (LBRYcrd node with a JSON-RPC server)" VALUE "FileVersion", VER_FILEVERSION_STR - VALUE "InternalName", "bitcoind" + VALUE "InternalName", "lbrycrdd" VALUE "LegalCopyright", COPYRIGHT_STR VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." - VALUE "OriginalFilename", "bitcoind.exe" - VALUE "ProductName", "bitcoind" + VALUE "OriginalFilename", "lbrycrdd.exe" + VALUE "ProductName", "lbrycrdd" VALUE "ProductVersion", VER_PRODUCTVERSION_STR END END diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 2da24e5e9..ecc52a0fa 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -61,7 +61,7 @@ static bool AppInit(int argc, char* argv[]) // // Parameters // - // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() + // If Qt is used, parameters/lbrycrd.conf are parsed in qt/bitcoin.cpp's main() SetupServerArgs(); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { @@ -114,7 +114,7 @@ static bool AppInit(int argc, char* argv[]) } } - // -server defaults to true for bitcoind but not for the GUI so do this here + // -server defaults to true for lbrycrdd but not for the GUI so do this here gArgs.SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(); @@ -185,7 +185,7 @@ int main(int argc, char* argv[]) { SetupEnvironment(); - // Connect bitcoind signal handlers + // Connect lbrycrdd signal handlers noui_connect(); return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/src/claimtrie.cpp b/src/claimtrie.cpp index 8b15b7065..b63c00296 100644 --- a/src/claimtrie.cpp +++ b/src/claimtrie.cpp @@ -2290,11 +2290,6 @@ int CClaimTrieCacheBase::getNumBlocksOfContinuousOwnership(const std::string& na const CClaimTrieNode* CClaimTrieCacheBase::getNodeForName(const std::string& name) const { - /* CClaimTrieNode* node = nullptr; */ - /* nodeCacheType::const_iterator itCache = cache.find(name); */ - /* if (itCache != cache.end()) */ - /* node = itCache->second; */ - /* return (node ? node : base->getNodeForName(name)); */ const CClaimTrieNode* node = nullptr; nodeCacheType::const_iterator itCache = cache.find(name); if (itCache != cache.end()) { diff --git a/src/leveldb/port/port_posix.cc b/src/leveldb/port/port_posix.cc index ec39e9219..4b80203bd 100644 --- a/src/leveldb/port/port_posix.cc +++ b/src/leveldb/port/port_posix.cc @@ -55,7 +55,7 @@ void InitOnce(OnceType* once, void (*initializer)()) { bool HasAcceleratedCRC32C() { #if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__) - unsigned int eax, ebx, ecx, edx; + unsigned int eax, ebx, ecx = 0, edx; __get_cpuid(1, &eax, &ebx, &ecx, &edx); return (ecx & (1 << 20)) != 0; #else diff --git a/src/leveldb/util/logging.cc b/src/leveldb/util/logging.cc index db6160c8f..6995d9021 100644 --- a/src/leveldb/util/logging.cc +++ b/src/leveldb/util/logging.cc @@ -52,7 +52,7 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { unsigned char c = (*in)[0]; if (c >= '0' && c <= '9') { ++digits; - const int delta = (c - '0'); + const unsigned int delta = (c - '0'); static const uint64_t kMaxUint64 = ~static_cast(0); if (v > kMaxUint64/10 || (v == kMaxUint64/10 && delta > kMaxUint64%10)) { diff --git a/src/test/claimtriebranching_tests.cpp b/src/test/claimtriebranching_tests.cpp index b09a713b6..b7be352c5 100644 --- a/src/test/claimtriebranching_tests.cpp +++ b/src/test/claimtriebranching_tests.cpp @@ -297,8 +297,8 @@ struct ClaimTrieChainFixture CTransaction GetCoinbase() { - assert(static_cast(coinbase_txs_used + 1) < coinbase_txs.size()); - return coinbase_txs[coinbase_txs_used++]; + auto tx = coinbase_txs.at(coinbase_txs_used++); + return tx; } //create i blocks diff --git a/src/test/claimtriecache_tests.cpp b/src/test/claimtriecache_tests.cpp index b67a68758..39536c16e 100644 --- a/src/test/claimtriecache_tests.cpp +++ b/src/test/claimtriecache_tests.cpp @@ -279,8 +279,8 @@ BOOST_AUTO_TEST_CASE(recursive_prune_test) BOOST_CHECK_EQUAL(1, cc.cacheSize()); nodeCacheType::iterator it = cc.getCache(std::string("t")); BOOST_CHECK_EQUAL(10, it->second->nHeightOfLastTakeover); - BOOST_CHECK_EQUAL(1, it->second->claims.size()); - BOOST_CHECK_EQUAL(0, it->second->children.size()); + BOOST_CHECK_EQUAL(1U, it->second->claims.size()); + BOOST_CHECK_EQUAL(0U, it->second->children.size()); } BOOST_AUTO_TEST_CASE(iteratetrie_test) diff --git a/src/validation.cpp b/src/validation.cpp index ab7d6774c..f53f21ff3 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2112,14 +2112,12 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl std::string value(vvchParams[1].begin(), vvchParams[1].end()); if (op == OP_CLAIM_NAME) { - assert(vvchParams.size() == 2); claimId = ClaimIdHash(txin.prevout.hash, txin.prevout.n); LogPrintf("+++ %s[%lu]: OP_CLAIM_NAME \"%s\"with claimId %s and tx prevout %s at index %d\n", __func__, pindex->nHeight, name, claimId.GetHex(), txin.prevout.hash.GetHex(), txin.prevout.n); } else if (op == OP_UPDATE_CLAIM) { - assert(vvchParams.size() == 3); claimId = uint160(vvchParams[1]); LogPrintf("+++ %s[%lu]: OP_UPDATE_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", __func__, pindex->nHeight, name, claimId.GetHex(), txin.prevout.hash.GetHex(), txin.prevout.n); @@ -2140,7 +2138,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl } else if (op == OP_SUPPORT_CLAIM) { - assert(vvchParams.size() == 2); uint160 supportedClaimId(vvchParams[1]); LogPrintf("+++ %s[%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", __func__, pindex->nHeight, name, @@ -2168,7 +2165,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl std::string name(vvchParams[0].begin(), vvchParams[0].end()); if (op == OP_CLAIM_NAME) { - assert(vvchParams.size() == 2); LogPrintf("%s: Inserting %s into the claim trie. Tx: %s, nOut: %d\n", __func__, name, tx.GetHash().GetHex(), j); if (!trieCache.addClaim(name, COutPoint(tx.GetHash(), j), ClaimIdHash(tx.GetHash(), j), txout.nValue, pindex->nHeight)) @@ -2178,7 +2174,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl } else if (op == OP_UPDATE_CLAIM) { - assert(vvchParams.size() == 3); uint160 claimId(vvchParams[1]); LogPrintf("%s: Got a claim update. Name: %s, claimId: %s, new txid: %s, nOut: %d\n", __func__, name, claimId.GetHex(), tx.GetHash().GetHex(), j); @@ -2200,7 +2195,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl } else if (op == OP_SUPPORT_CLAIM) { - assert(vvchParams.size() == 2); uint160 supportedClaimId(vvchParams[1]); if (!trieCache.addSupport(name, COutPoint(tx.GetHash(), j), txout.nValue, supportedClaimId, pindex->nHeight)) {