pulled in a few minor keepers from the other rebase branch
This commit is contained in:
parent
9ad7b0c90f
commit
e7d7d0861b
16 changed files with 37 additions and 212 deletions
|
@ -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)
|
|
@ -55,7 +55,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".
|
||||
|
|
|
@ -9,7 +9,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])
|
||||
|
@ -693,7 +693,9 @@ if test x$ac_cv_sys_large_files != x &&
|
|||
CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files"
|
||||
fi
|
||||
|
||||
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])
|
||||
|
@ -1554,7 +1556,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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,7 +56,7 @@ static void SetupCliArgs()
|
|||
gArgs.AddArg("-rpcport=<port>", strprintf("Connect to JSON-RPC on <port> (default: %u, testnet: %u, regtest: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort(), regtestBaseParams->RPCPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-rpcwait", "Wait for RPC server to start", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-rpcwallet=<walletname>", "Send RPC for non-default wallet on RPC server (needs to exactly match corresponding -wallet option passed to bitcoind). This changes the RPC endpoint used, e.g. http://127.0.0.1:8332/wallet/<walletname>", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-rpcwallet=<walletname>", "Send RPC for non-default wallet on RPC server (needs to exactly match corresponding -wallet option passed to lbrycrd). This changes the RPC endpoint used, e.g. http://127.0.0.1:8332/wallet/<walletname>", ArgsManager::ALLOW_ANY, 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.", ArgsManager::ALLOW_ANY, 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.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
}
|
||||
|
@ -387,7 +387,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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -50,7 +50,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)) {
|
||||
|
@ -97,7 +97,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();
|
||||
|
@ -170,7 +170,7 @@ int main(int argc, char* argv[])
|
|||
#endif
|
||||
SetupEnvironment();
|
||||
|
||||
// Connect bitcoind signal handlers
|
||||
// Connect lbrycrdd signal handlers
|
||||
noui_connect();
|
||||
|
||||
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<uint64_t>(0);
|
||||
if (v > kMaxUint64/10 ||
|
||||
(v == kMaxUint64/10 && delta > kMaxUint64%10)) {
|
||||
|
|
|
@ -297,8 +297,8 @@ struct ClaimTrieChainFixture
|
|||
|
||||
CTransaction GetCoinbase()
|
||||
{
|
||||
assert(static_cast<size_t>(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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -17,4 +17,4 @@ std::string FormatStateMessage(const CValidationState &state)
|
|||
state.GetRejectCode());
|
||||
}
|
||||
|
||||
const std::string strMessageMagic = "Bitcoin Signed Message:\n";
|
||||
const std::string strMessageMagic = "LBRYcrd Signed Message:\n";
|
||||
|
|
|
@ -2385,14 +2385,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);
|
||||
|
@ -2413,7 +2411,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,
|
||||
|
@ -2441,7 +2438,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))
|
||||
|
@ -2451,7 +2447,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);
|
||||
|
@ -2473,7 +2468,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))
|
||||
{
|
||||
|
|
164
src/validation.h
164
src/validation.h
|
@ -326,170 +326,6 @@ bool TestLockPointValidity(const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_mai
|
|||
*/
|
||||
bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flags, LockPoints* lp = nullptr, bool useExistingLockPoints = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
/************************************************************
|
||||
* LBRY moved these from validation.cpp, for testcase & RPC usage
|
||||
* BEGIN
|
||||
************************************************************/
|
||||
|
||||
/**
|
||||
* Global state
|
||||
*/
|
||||
struct CBlockIndexWorkComparator
|
||||
{
|
||||
bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
|
||||
// First sort by most total work, ...
|
||||
if (pa->nChainWork > pb->nChainWork) return false;
|
||||
if (pa->nChainWork < pb->nChainWork) return true;
|
||||
|
||||
// ... then by earliest time received, ...
|
||||
if (pa->nSequenceId < pb->nSequenceId) return false;
|
||||
if (pa->nSequenceId > pb->nSequenceId) return true;
|
||||
|
||||
// Use pointer address as tie breaker (should only happen with blocks
|
||||
// loaded from disk, as those all have id 0).
|
||||
if (pa < pb) return false;
|
||||
if (pa > pb) return true;
|
||||
|
||||
// Identical blocks.
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class ConnectTrace;
|
||||
|
||||
enum DisconnectResult
|
||||
{
|
||||
DISCONNECT_OK, // All good.
|
||||
DISCONNECT_UNCLEAN, // Rolled back, but UTXO set was inconsistent with block.
|
||||
DISCONNECT_FAILED // Something else went wrong.
|
||||
};
|
||||
|
||||
/**
|
||||
* CChainState stores and provides an API to update our local knowledge of the
|
||||
* current best chain and header tree.
|
||||
*
|
||||
* It generally provides access to the current block tree, as well as functions
|
||||
* to provide new data, which it will appropriately validate and incorporate in
|
||||
* its state as necessary.
|
||||
*
|
||||
* Eventually, the API here is targeted at being exposed externally as a
|
||||
* consumable libconsensus library, so any functions added must only call
|
||||
* other class member functions, pure functions in other parts of the consensus
|
||||
* library, callbacks via the validation interface, or read/write-to-disk
|
||||
* functions (eventually this will also be via callbacks).
|
||||
*/
|
||||
class CChainState {
|
||||
private:
|
||||
/**
|
||||
* The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and
|
||||
* as good as our current tip or better. Entries may be failed, though, and pruning nodes may be
|
||||
* missing the data for the block.
|
||||
*/
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexCandidates;
|
||||
|
||||
/**
|
||||
* Every received block is assigned a unique and increasing identifier, so we
|
||||
* know which one to give priority in case of a fork.
|
||||
*/
|
||||
CCriticalSection cs_nBlockSequenceId;
|
||||
/** Blocks loaded from disk are assigned id 0, so start the counter at 1. */
|
||||
int32_t nBlockSequenceId = 1;
|
||||
/** Decreasing counter (used by subsequent preciousblock calls). */
|
||||
int32_t nBlockReverseSequenceId = -1;
|
||||
/** chainwork for the last block that preciousblock has been applied to. */
|
||||
arith_uint256 nLastPreciousChainwork = 0;
|
||||
|
||||
/** In order to efficiently track invalidity of headers, we keep the set of
|
||||
* blocks which we tried to connect and found to be invalid here (ie which
|
||||
* were set to BLOCK_FAILED_VALID since the last restart). We can then
|
||||
* walk this set and check if a new header is a descendant of something in
|
||||
* this set, preventing us from having to walk mapBlockIndex when we try
|
||||
* to connect a bad block and fail.
|
||||
*
|
||||
* While this is more complicated than marking everything which descends
|
||||
* from an invalid block as invalid at the time we discover it to be
|
||||
* invalid, doing so would require walking all of mapBlockIndex to find all
|
||||
* descendants. Since this case should be very rare, keeping track of all
|
||||
* BLOCK_FAILED_VALID blocks in a set should be just fine and work just as
|
||||
* well.
|
||||
*
|
||||
* Because we already walk mapBlockIndex in height-order at startup, we go
|
||||
* ahead and mark descendants of invalid blocks as FAILED_CHILD at that time,
|
||||
* instead of putting things in this set.
|
||||
*/
|
||||
std::set<CBlockIndex*> m_failed_blocks;
|
||||
|
||||
/**
|
||||
* the ChainState CriticalSection
|
||||
* A lock that must be held when modifying this ChainState - held in ActivateBestChain()
|
||||
*/
|
||||
CCriticalSection m_cs_chainstate;
|
||||
|
||||
public:
|
||||
CChain chainActive;
|
||||
BlockMap mapBlockIndex;
|
||||
std::multimap<CBlockIndex*, CBlockIndex*> mapBlocksUnlinked;
|
||||
CBlockIndex *pindexBestInvalid = nullptr;
|
||||
|
||||
bool LoadBlockIndex(const Consensus::Params& consensus_params, CBlockTreeDB& blocktree) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock);
|
||||
|
||||
/**
|
||||
* If a block header hasn't already been seen, call CheckBlockHeader on it, ensure
|
||||
* that it doesn't descend from an invalid block, and then add it to mapBlockIndex.
|
||||
*/
|
||||
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
// Block (dis)connection on a given view:
|
||||
DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex* pindex, CCoinsViewCache& view, CClaimTrieCache& trieCache);
|
||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex,
|
||||
CCoinsViewCache& view, CClaimTrieCache& trieCache, const CChainParams& chainparams, bool fJustCheck = false);
|
||||
|
||||
// Block disconnection on our pcoinsTip:
|
||||
bool DisconnectTip(CValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool);
|
||||
|
||||
// Manual block validity manipulation:
|
||||
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
|
||||
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
|
||||
bool RewindBlockIndex(const CChainParams& params);
|
||||
bool LoadGenesisBlock(const CChainParams& chainparams);
|
||||
|
||||
void PruneBlockIndexCandidates();
|
||||
|
||||
void UnloadBlockIndex();
|
||||
|
||||
private:
|
||||
bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace);
|
||||
bool ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool);
|
||||
|
||||
CBlockIndex* AddToBlockIndex(const CBlockHeader& block) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
/** Create a new block index entry for a given block hash */
|
||||
CBlockIndex* InsertBlockIndex(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
/**
|
||||
* Make various assertions about the state of the block index.
|
||||
*
|
||||
* By default this only executes fully when using the Regtest chain; see: fCheckBlockIndex.
|
||||
*/
|
||||
void CheckBlockIndex(const Consensus::Params& consensusParams);
|
||||
|
||||
void InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state);
|
||||
CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
void ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const CDiskBlockPos& pos, const Consensus::Params& consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
|
||||
bool RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs, const CChainParams& params) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
};
|
||||
|
||||
/************************************************************
|
||||
* LBRY moved these from validation.cpp, for testcase & RPC usage
|
||||
* END
|
||||
************************************************************/
|
||||
|
||||
/**
|
||||
* Closure representing one script verification
|
||||
* Note that this stores references to the spending transaction
|
||||
|
|
Loading…
Reference in a new issue