|
|
@ -16,6 +16,7 @@
|
|
|
|
#include <consensus/validation.h>
|
|
|
|
#include <consensus/validation.h>
|
|
|
|
#include <cuckoocache.h>
|
|
|
|
#include <cuckoocache.h>
|
|
|
|
#include <hash.h>
|
|
|
|
#include <hash.h>
|
|
|
|
|
|
|
|
#include <index/txindex.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <policy/fees.h>
|
|
|
|
#include <policy/fees.h>
|
|
|
|
#include <policy/policy.h>
|
|
|
|
#include <policy/policy.h>
|
|
|
@ -217,7 +218,6 @@ uint256 g_best_block;
|
|
|
|
int nScriptCheckThreads = 0;
|
|
|
|
int nScriptCheckThreads = 0;
|
|
|
|
std::atomic_bool fImporting(false);
|
|
|
|
std::atomic_bool fImporting(false);
|
|
|
|
std::atomic_bool fReindex(false);
|
|
|
|
std::atomic_bool fReindex(false);
|
|
|
|
bool fTxIndex = false;
|
|
|
|
|
|
|
|
bool fHavePruned = false;
|
|
|
|
bool fHavePruned = false;
|
|
|
|
bool fPruneMode = false;
|
|
|
|
bool fPruneMode = false;
|
|
|
|
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
|
|
|
|
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
|
|
|
@ -1028,9 +1028,9 @@ bool GetTransaction(const uint256& hash, CTransactionRef& txOut, const Consensus
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fTxIndex) {
|
|
|
|
if (g_txindex) {
|
|
|
|
CDiskTxPos postx;
|
|
|
|
CDiskTxPos postx;
|
|
|
|
if (pblocktree->ReadTxIndex(hash, postx)) {
|
|
|
|
if (g_txindex->FindTx(hash, postx)) {
|
|
|
|
CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION);
|
|
|
|
CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION);
|
|
|
|
if (file.IsNull())
|
|
|
|
if (file.IsNull())
|
|
|
|
return error("%s: OpenBlockFile failed", __func__);
|
|
|
|
return error("%s: OpenBlockFile failed", __func__);
|
|
|
@ -1668,26 +1668,6 @@ static bool WriteUndoDataForBlock(const CBlockUndo& blockundo, CValidationState&
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool WriteTxIndexDataForBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!fTxIndex) return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
|
|
|
|
|
|
|
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
|
|
|
|
|
|
|
|
vPos.reserve(block.vtx.size());
|
|
|
|
|
|
|
|
for (const CTransactionRef& tx : block.vtx)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vPos.push_back(std::make_pair(tx->GetHash(), pos));
|
|
|
|
|
|
|
|
pos.nTxOffset += ::GetSerializeSize(*tx, SER_DISK, CLIENT_VERSION);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pblocktree->WriteTxIndex(vPos)) {
|
|
|
|
|
|
|
|
return AbortNode(state, "Failed to write transaction index");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
|
|
|
static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadScriptCheck() {
|
|
|
|
void ThreadScriptCheck() {
|
|
|
@ -2079,9 +2059,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
|
|
|
setDirtyBlockIndex.insert(pindex);
|
|
|
|
setDirtyBlockIndex.insert(pindex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!WriteTxIndexDataForBlock(block, state, pindex))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(pindex->phashBlock);
|
|
|
|
assert(pindex->phashBlock);
|
|
|
|
// add this block to the view's block chain
|
|
|
|
// add this block to the view's block chain
|
|
|
|
view.SetBestBlock(pindex->GetBlockHash());
|
|
|
|
view.SetBestBlock(pindex->GetBlockHash());
|
|
|
@ -3903,10 +3880,6 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
|
|
|
pblocktree->ReadReindexing(fReindexing);
|
|
|
|
pblocktree->ReadReindexing(fReindexing);
|
|
|
|
if(fReindexing) fReindex = true;
|
|
|
|
if(fReindexing) fReindex = true;
|
|
|
|
|
|
|
|
|
|
|
|
// Check whether we have a transaction index
|
|
|
|
|
|
|
|
pblocktree->ReadFlag("txindex", fTxIndex);
|
|
|
|
|
|
|
|
LogPrintf("%s: transaction index %s\n", __func__, fTxIndex ? "enabled" : "disabled");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -4300,9 +4273,6 @@ bool LoadBlockIndex(const CChainParams& chainparams)
|
|
|
|
// needs_init.
|
|
|
|
// needs_init.
|
|
|
|
|
|
|
|
|
|
|
|
LogPrintf("Initializing databases...\n");
|
|
|
|
LogPrintf("Initializing databases...\n");
|
|
|
|
// Use the provided setting for -txindex in the new database
|
|
|
|
|
|
|
|
fTxIndex = gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX);
|
|
|
|
|
|
|
|
pblocktree->WriteFlag("txindex", fTxIndex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|