mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Call AcceptBlock with the block's shared_ptr instead of CBlock&
This commit is contained in:
parent
c99dd97339
commit
d28172f57e
@ -3544,8 +3544,10 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
|
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
|
||||||
static bool AcceptBlock(const CBlock& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock)
|
static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, const CDiskBlockPos* dbp, bool* fNewBlock)
|
||||||
{
|
{
|
||||||
|
const CBlock& block = *pblock;
|
||||||
|
|
||||||
if (fNewBlock) *fNewBlock = false;
|
if (fNewBlock) *fNewBlock = false;
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
@ -3625,7 +3627,7 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
|
|||||||
CBlockIndex *pindex = NULL;
|
CBlockIndex *pindex = NULL;
|
||||||
if (fNewBlock) *fNewBlock = false;
|
if (fNewBlock) *fNewBlock = false;
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
bool ret = AcceptBlock(*pblock, state, chainparams, &pindex, fForceProcessing, NULL, fNewBlock);
|
bool ret = AcceptBlock(pblock, state, chainparams, &pindex, fForceProcessing, NULL, fNewBlock);
|
||||||
CheckBlockIndex(chainparams.GetConsensus());
|
CheckBlockIndex(chainparams.GetConsensus());
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
GetMainSignals().BlockChecked(*pblock, state);
|
GetMainSignals().BlockChecked(*pblock, state);
|
||||||
@ -4239,7 +4241,8 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
|||||||
dbp->nPos = nBlockPos;
|
dbp->nPos = nBlockPos;
|
||||||
blkdat.SetLimit(nBlockPos + nSize);
|
blkdat.SetLimit(nBlockPos + nSize);
|
||||||
blkdat.SetPos(nBlockPos);
|
blkdat.SetPos(nBlockPos);
|
||||||
CBlock block;
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||||
|
CBlock& block = *pblock;
|
||||||
blkdat >> block;
|
blkdat >> block;
|
||||||
nRewind = blkdat.GetPos();
|
nRewind = blkdat.GetPos();
|
||||||
|
|
||||||
@ -4257,7 +4260,7 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
|||||||
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) {
|
if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if (AcceptBlock(block, state, chainparams, NULL, true, dbp, NULL))
|
if (AcceptBlock(pblock, state, chainparams, NULL, true, dbp, NULL))
|
||||||
nLoaded++;
|
nLoaded++;
|
||||||
if (state.IsError())
|
if (state.IsError())
|
||||||
break;
|
break;
|
||||||
@ -4284,16 +4287,17 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
|
|||||||
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
||||||
if (ReadBlockFromDisk(block, it->second, chainparams.GetConsensus()))
|
std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBlock>();
|
||||||
|
if (ReadBlockFromDisk(*pblockrecursive, it->second, chainparams.GetConsensus()))
|
||||||
{
|
{
|
||||||
LogPrint("reindex", "%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
LogPrint("reindex", "%s: Processing out of order child %s of %s\n", __func__, pblockrecursive->GetHash().ToString(),
|
||||||
head.ToString());
|
head.ToString());
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CValidationState dummy;
|
CValidationState dummy;
|
||||||
if (AcceptBlock(block, dummy, chainparams, NULL, true, &it->second, NULL))
|
if (AcceptBlock(pblockrecursive, dummy, chainparams, NULL, true, &it->second, NULL))
|
||||||
{
|
{
|
||||||
nLoaded++;
|
nLoaded++;
|
||||||
queue.push_back(block.GetHash());
|
queue.push_back(pblockrecursive->GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
range.first++;
|
range.first++;
|
||||||
|
Loading…
Reference in New Issue
Block a user