Globals: Explicit Consensus::Params arg for main:
-CheckBlockIndex -DisconnectTip -GetTransaction -InvalidateBlock -ProcessGetData -ReadBlockFromDisk
This commit is contained in:
parent
cea06a4fd3
commit
71cf6ba98b
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "amqppublishnotifier.h"
|
||||
#include "chainparams.h"
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -152,11 +153,12 @@ bool AMQPPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
|
|||
{
|
||||
LogPrint("amqp", "amqp: Publish rawblock %s\n", pindex->GetBlockHash().GetHex());
|
||||
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
CBlock block;
|
||||
if(!ReadBlockFromDisk(block, pindex)) {
|
||||
if(!ReadBlockFromDisk(block, pindex, consensusParams)) {
|
||||
LogPrint("amqp", "amqp: Can't read block from disk");
|
||||
return false;
|
||||
}
|
||||
|
|
73
src/main.cpp
73
src/main.cpp
|
@ -104,7 +104,7 @@ void EraseOrphansFor(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|||
* in the last Consensus::Params::nMajorityWindow blocks, starting at pstart and going backwards.
|
||||
*/
|
||||
static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams);
|
||||
static void CheckBlockIndex();
|
||||
static void CheckBlockIndex(const Consensus::Params& consensusParams);
|
||||
|
||||
/** Constant stuff for coinbase transactions we create: */
|
||||
CScript COINBASE_FLAGS;
|
||||
|
@ -1607,7 +1607,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||
}
|
||||
|
||||
/** Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock */
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::Params& consensusParams, uint256 &hashBlock, bool fAllowSlow)
|
||||
{
|
||||
CBlockIndex *pindexSlow = NULL;
|
||||
|
||||
|
@ -1653,7 +1653,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||
|
||||
if (pindexSlow) {
|
||||
CBlock block;
|
||||
if (ReadBlockFromDisk(block, pindexSlow)) {
|
||||
if (ReadBlockFromDisk(block, pindexSlow, consensusParams)) {
|
||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
if (tx.GetHash() == hash) {
|
||||
txOut = tx;
|
||||
|
@ -1698,7 +1698,7 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams)
|
||||
{
|
||||
block.SetNull();
|
||||
|
||||
|
@ -1716,16 +1716,16 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||
}
|
||||
|
||||
// Check the header
|
||||
if (!(CheckEquihashSolution(&block, Params().GetConsensus()) &&
|
||||
CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||
if (!(CheckEquihashSolution(&block, consensusParams) &&
|
||||
CheckProofOfWork(block.GetHash(), block.nBits, consensusParams)))
|
||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||
{
|
||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos(), consensusParams))
|
||||
return false;
|
||||
if (block.GetHash() != pindex->GetBlockHash())
|
||||
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||
|
@ -3019,12 +3019,12 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||
* Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and
|
||||
* mempool.removeWithoutBranchId after this, with cs_main held.
|
||||
*/
|
||||
bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
bool static DisconnectTip(CValidationState &state, const Consensus::Params& consensusParams, bool fBare = false) {
|
||||
CBlockIndex *pindexDelete = chainActive.Tip();
|
||||
assert(pindexDelete);
|
||||
// Read block from disk.
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindexDelete))
|
||||
if (!ReadBlockFromDisk(block, pindexDelete, consensusParams))
|
||||
return AbortNode(state, "Failed to read block");
|
||||
// Apply the block atomically to the chain state.
|
||||
uint256 sproutAnchorBeforeDisconnect = pcoinsTip->GetBestAnchor(SPROUT);
|
||||
|
@ -3094,12 +3094,13 @@ static int64_t nTimePostConnect = 0;
|
|||
* You probably want to call mempool.removeWithoutBranchId after this, with cs_main held.
|
||||
*/
|
||||
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, const CBlock *pblock) {
|
||||
const CChainParams& chainparams = Params();
|
||||
assert(pindexNew->pprev == chainActive.Tip());
|
||||
// Read block from disk.
|
||||
int64_t nTime1 = GetTimeMicros();
|
||||
CBlock block;
|
||||
if (!pblock) {
|
||||
if (!ReadBlockFromDisk(block, pindexNew))
|
||||
if (!ReadBlockFromDisk(block, pindexNew, chainparams.GetConsensus()))
|
||||
return AbortNode(state, "Failed to read block");
|
||||
pblock = █
|
||||
}
|
||||
|
@ -3237,6 +3238,7 @@ static void PruneBlockIndexCandidates() {
|
|||
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
||||
*/
|
||||
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, const CBlock *pblock) {
|
||||
const CChainParams& chainparams = Params();
|
||||
AssertLockHeld(cs_main);
|
||||
bool fInvalidFound = false;
|
||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||
|
@ -3270,7 +3272,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||
// Disconnect active blocks which are no longer in the best chain.
|
||||
bool fBlocksDisconnected = false;
|
||||
while (chainActive.Tip() && chainActive.Tip() != pindexFork) {
|
||||
if (!DisconnectTip(state))
|
||||
if (!DisconnectTip(state, chainparams.GetConsensus()))
|
||||
return false;
|
||||
fBlocksDisconnected = true;
|
||||
}
|
||||
|
@ -3342,7 +3344,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||
bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
|
||||
CBlockIndex *pindexNewTip = NULL;
|
||||
CBlockIndex *pindexMostWork = NULL;
|
||||
const CChainParams& chainParams = Params();
|
||||
const CChainParams& chainparams = Params();
|
||||
do {
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
|
@ -3369,7 +3371,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
|
|||
// Relay inventory, but don't relay old inventory during initial block download.
|
||||
int nBlockEstimate = 0;
|
||||
if (fCheckpointsEnabled)
|
||||
nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints());
|
||||
nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints());
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
|
@ -3381,7 +3383,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
|
|||
uiInterface.NotifyBlockTip(hashNewTip);
|
||||
}
|
||||
} while(pindexMostWork != chainActive.Tip());
|
||||
CheckBlockIndex();
|
||||
CheckBlockIndex(chainparams.GetConsensus());
|
||||
|
||||
// Write changes periodically to disk, after relay.
|
||||
if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) {
|
||||
|
@ -3391,7 +3393,8 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
|
||||
bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex *pindex)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
// Mark the block itself as invalid.
|
||||
|
@ -3406,10 +3409,10 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
|
|||
setBlockIndexCandidates.erase(pindexWalk);
|
||||
// ActivateBestChain considers blocks already in chainActive
|
||||
// unconditionally valid already, so force disconnect away from it.
|
||||
if (!DisconnectTip(state)) {
|
||||
if (!DisconnectTip(state, consensusParams)) {
|
||||
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
|
||||
mempool.removeWithoutBranchId(
|
||||
CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, Params().GetConsensus()));
|
||||
CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, consensusParams));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3427,7 +3430,7 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
|
|||
InvalidChainFound(pindex);
|
||||
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
|
||||
mempool.removeWithoutBranchId(
|
||||
CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, Params().GetConsensus()));
|
||||
CurrentEpochBranchId(chainActive.Tip()->nHeight + 1, consensusParams));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4019,6 +4022,7 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
|
|||
|
||||
bool ProcessNewBlock(CValidationState &state, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
// Preliminary checks
|
||||
auto verifier = libzcash::ProofVerifier::Disabled();
|
||||
bool checked = CheckBlock(*pblock, state, verifier);
|
||||
|
@ -4037,7 +4041,7 @@ bool ProcessNewBlock(CValidationState &state, const CNode* pfrom, const CBlock*
|
|||
if (pindex && pfrom) {
|
||||
mapBlockSource[pindex->GetBlockHash()] = pfrom->GetId();
|
||||
}
|
||||
CheckBlockIndex();
|
||||
CheckBlockIndex(chainparams.GetConsensus());
|
||||
if (!ret)
|
||||
return error("%s: AcceptBlock FAILED", __func__);
|
||||
}
|
||||
|
@ -4432,6 +4436,7 @@ CVerifyDB::~CVerifyDB()
|
|||
|
||||
bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
LOCK(cs_main);
|
||||
if (chainActive.Tip() == NULL || chainActive.Tip()->pprev == NULL)
|
||||
return true;
|
||||
|
@ -4458,7 +4463,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||
break;
|
||||
CBlock block;
|
||||
// check level 0: read from disk
|
||||
if (!ReadBlockFromDisk(block, pindex))
|
||||
if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus()))
|
||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
// check level 1: verify block validity
|
||||
if (nCheckLevel >= 1 && !CheckBlock(block, state, verifier))
|
||||
|
@ -4501,7 +4506,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||
uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, 100 - (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * 50))));
|
||||
pindex = chainActive.Next(pindex);
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindex))
|
||||
if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus()))
|
||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
if (!ConnectBlock(block, state, pindex, coins))
|
||||
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||
|
@ -4597,7 +4602,7 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
|||
// of the blockchain).
|
||||
break;
|
||||
}
|
||||
if (!DisconnectTip(state, true)) {
|
||||
if (!DisconnectTip(state, params.GetConsensus(), true)) {
|
||||
return error("RewindBlockIndex: unable to disconnect block at height %i", pindex->nHeight);
|
||||
}
|
||||
// Occasionally flush state to disk.
|
||||
|
@ -4659,7 +4664,7 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
|||
|
||||
PruneBlockIndexCandidates();
|
||||
|
||||
CheckBlockIndex();
|
||||
CheckBlockIndex(params.GetConsensus());
|
||||
|
||||
if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) {
|
||||
return false;
|
||||
|
@ -4837,7 +4842,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
||||
while (range.first != range.second) {
|
||||
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
||||
if (ReadBlockFromDisk(block, it->second))
|
||||
if (ReadBlockFromDisk(block, it->second, chainparams.GetConsensus()))
|
||||
{
|
||||
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||
head.ToString());
|
||||
|
@ -4864,9 +4869,8 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||
return nLoaded > 0;
|
||||
}
|
||||
|
||||
void static CheckBlockIndex()
|
||||
void static CheckBlockIndex(const Consensus::Params& consensusParams)
|
||||
{
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
if (!fCheckBlockIndex) {
|
||||
return;
|
||||
}
|
||||
|
@ -5151,7 +5155,7 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
|||
return true;
|
||||
}
|
||||
|
||||
void static ProcessGetData(CNode* pfrom)
|
||||
void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParams)
|
||||
{
|
||||
int currentHeight = GetHeight();
|
||||
|
||||
|
@ -5198,7 +5202,7 @@ void static ProcessGetData(CNode* pfrom)
|
|||
{
|
||||
// Send block from disk
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, (*mi).second))
|
||||
if (!ReadBlockFromDisk(block, (*mi).second, consensusParams))
|
||||
assert(!"cannot load block from disk");
|
||||
if (inv.type == MSG_BLOCK)
|
||||
pfrom->PushMessage("block", block);
|
||||
|
@ -5630,7 +5634,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||
LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);
|
||||
|
||||
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
||||
ProcessGetData(pfrom);
|
||||
ProcessGetData(pfrom, chainparams.GetConsensus());
|
||||
}
|
||||
|
||||
|
||||
|
@ -5904,7 +5908,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256());
|
||||
}
|
||||
|
||||
CheckBlockIndex();
|
||||
CheckBlockIndex(chainparams.GetConsensus());
|
||||
}
|
||||
|
||||
else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing
|
||||
|
@ -6208,6 +6212,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||
// requires LOCK(cs_vRecvMsg)
|
||||
bool ProcessMessages(CNode* pfrom)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
//if (fDebug)
|
||||
// LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
|
||||
|
||||
|
@ -6222,7 +6227,7 @@ bool ProcessMessages(CNode* pfrom)
|
|||
bool fOk = true;
|
||||
|
||||
if (!pfrom->vRecvGetData.empty())
|
||||
ProcessGetData(pfrom);
|
||||
ProcessGetData(pfrom, chainparams.GetConsensus());
|
||||
|
||||
// this maintains the order of responses
|
||||
if (!pfrom->vRecvGetData.empty()) return fOk;
|
||||
|
@ -6249,7 +6254,7 @@ bool ProcessMessages(CNode* pfrom)
|
|||
it++;
|
||||
|
||||
// Scan for message start
|
||||
if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) {
|
||||
if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), MESSAGE_START_SIZE) != 0) {
|
||||
LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id);
|
||||
fOk = false;
|
||||
break;
|
||||
|
@ -6257,7 +6262,7 @@ bool ProcessMessages(CNode* pfrom)
|
|||
|
||||
// Read header
|
||||
CMessageHeader& hdr = msg.hdr;
|
||||
if (!hdr.IsValid(Params().MessageStart()))
|
||||
if (!hdr.IsValid(chainparams.MessageStart()))
|
||||
{
|
||||
LogPrintf("PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(hdr.GetCommand()), pfrom->id);
|
||||
continue;
|
||||
|
|
12
src/main.h
12
src/main.h
|
@ -239,7 +239,7 @@ bool IsInitialBlockDownload();
|
|||
/** Format a string that describes several potential problems detected by the core */
|
||||
std::string GetWarnings(const std::string& strFor);
|
||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false);
|
||||
/** Find the best known block, and make it the tip of the block chain */
|
||||
bool ActivateBestChain(CValidationState &state, const CBlock *pblock = NULL);
|
||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||
|
@ -462,9 +462,8 @@ public:
|
|||
|
||||
/** Functions for disk access for blocks */
|
||||
bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart);
|
||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
||||
|
||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams);
|
||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams);
|
||||
|
||||
/** Functions for validating blocks and updating the block tree */
|
||||
|
||||
|
@ -492,8 +491,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||
* If dbp is non-NULL, the file is known to already reside on disk
|
||||
*/
|
||||
bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
|
||||
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL);
|
||||
|
||||
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex **ppindex= NULL);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -572,7 +570,7 @@ public:
|
|||
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
|
||||
|
||||
/** Mark a block as invalid. */
|
||||
bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex);
|
||||
bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex *pindex);
|
||||
|
||||
/** Remove invalidity status from a block and its descendants. */
|
||||
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "primitives/block.h"
|
||||
#include "primitives/transaction.h"
|
||||
#include "main.h"
|
||||
|
@ -214,7 +215,7 @@ static bool rest_block(HTTPRequest* req,
|
|||
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
|
||||
|
||||
if (!ReadBlockFromDisk(block, pblockindex))
|
||||
if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
|
||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||
}
|
||||
|
||||
|
@ -355,7 +356,7 @@ static bool rest_tx(HTTPRequest* req, const std::string& strURIPart)
|
|||
|
||||
CTransaction tx;
|
||||
uint256 hashBlock = uint256();
|
||||
if (!GetTransaction(hash, tx, hashBlock, true))
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
|
|
@ -493,7 +493,7 @@ UniValue getblock(const UniValue& params, bool fHelp)
|
|||
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
|
||||
|
||||
if(!ReadBlockFromDisk(block, pblockindex))
|
||||
if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||
|
||||
if (verbosity == 0)
|
||||
|
@ -976,7 +976,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||
|
||||
CBlockIndex* pblockindex = mapBlockIndex[hash];
|
||||
InvalidateBlock(state, pblockindex);
|
||||
InvalidateBlock(state, Params().GetConsensus(), pblockindex);
|
||||
}
|
||||
|
||||
if (state.IsValid()) {
|
||||
|
|
|
@ -322,7 +322,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
|
|||
|
||||
CTransaction tx;
|
||||
uint256 hashBlock;
|
||||
if (!GetTransaction(hash, tx, hashBlock, true))
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
|
||||
string strHex = EncodeHexTx(tx);
|
||||
|
@ -392,7 +392,7 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
|
|||
if (pblockindex == NULL)
|
||||
{
|
||||
CTransaction tx;
|
||||
if (!GetTransaction(oneTxid, tx, hashBlock, false) || hashBlock.IsNull())
|
||||
if (!GetTransaction(oneTxid, tx, Params().GetConsensus(), hashBlock, false) || hashBlock.IsNull())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block");
|
||||
if (!mapBlockIndex.count(hashBlock))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Transaction index corrupt");
|
||||
|
@ -400,7 +400,7 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
CBlock block;
|
||||
if(!ReadBlockFromDisk(block, pblockindex))
|
||||
if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||
|
||||
unsigned int ntxFound = 0;
|
||||
|
|
|
@ -82,7 +82,7 @@ UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp)
|
|||
uint256 hashBlock;
|
||||
|
||||
// Check txid has been seen
|
||||
if (!GetTransaction(hash, tx, hashBlock, true)) {
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp)
|
|||
CTransaction tx;
|
||||
uint256 hashBlock;
|
||||
// Check if we have seen the transaction
|
||||
if (!GetTransaction(hash, tx, hashBlock, true)) {
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
}
|
||||
|
||||
|
|
|
@ -1134,7 +1134,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
|||
const CBlock* pblock {pblockIn};
|
||||
CBlock block;
|
||||
if (!pblock) {
|
||||
ReadBlockFromDisk(block, pindex);
|
||||
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
|
||||
pblock = █
|
||||
}
|
||||
|
||||
|
@ -2432,7 +2432,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
|||
|
||||
while (pindex) {
|
||||
CBlock block;
|
||||
ReadBlockFromDisk(block, pindex);
|
||||
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
|
||||
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||
{
|
||||
|
@ -2511,7 +2511,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
|||
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
||||
|
||||
CBlock block;
|
||||
ReadBlockFromDisk(block, pindex);
|
||||
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
|
||||
BOOST_FOREACH(CTransaction& tx, block.vtx)
|
||||
{
|
||||
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "zmqpublishnotifier.h"
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
|
@ -164,11 +165,12 @@ bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
|
|||
{
|
||||
LogPrint("zmq", "zmq: Publish rawblock %s\n", pindex->GetBlockHash().GetHex());
|
||||
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
CBlock block;
|
||||
if(!ReadBlockFromDisk(block, pindex))
|
||||
if(!ReadBlockFromDisk(block, pindex, consensusParams))
|
||||
{
|
||||
zmqError("Can't read block from disk");
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue