@@ -3047,8 +3047,10 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
3047
3047
}
3048
3048
3049
3049
/* * Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
3050
- static bool AcceptBlock (const CBlock& block , CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested , const CDiskBlockPos* dbp, bool * fNewBlock )
3050
+ static bool AcceptBlock (const std::shared_ptr< const CBlock>& pblock , CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested , const CDiskBlockPos* dbp, bool * fNewBlock )
3051
3051
{
3052
+ const CBlock& block = *pblock;
3053
+
3052
3054
if (fNewBlock ) *fNewBlock = false ;
3053
3055
AssertLockHeld (cs_main);
3054
3056
@@ -3128,7 +3130,7 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
3128
3130
CBlockIndex *pindex = NULL ;
3129
3131
if (fNewBlock ) *fNewBlock = false ;
3130
3132
CValidationState state;
3131
- bool ret = AcceptBlock (* pblock, state, chainparams, &pindex, fForceProcessing , NULL , fNewBlock );
3133
+ bool ret = AcceptBlock (pblock, state, chainparams, &pindex, fForceProcessing , NULL , fNewBlock );
3132
3134
CheckBlockIndex (chainparams.GetConsensus ());
3133
3135
if (!ret) {
3134
3136
GetMainSignals ().BlockChecked (*pblock, state);
@@ -3755,7 +3757,8 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
3755
3757
dbp->nPos = nBlockPos;
3756
3758
blkdat.SetLimit (nBlockPos + nSize);
3757
3759
blkdat.SetPos (nBlockPos);
3758
- CBlock block;
3760
+ std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
3761
+ CBlock& block = *pblock;
3759
3762
blkdat >> block;
3760
3763
nRewind = blkdat.GetPos ();
3761
3764
@@ -3773,7 +3776,7 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
3773
3776
if (mapBlockIndex.count (hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0 ) {
3774
3777
LOCK (cs_main);
3775
3778
CValidationState state;
3776
- if (AcceptBlock (block , state, chainparams, NULL , true , dbp, NULL ))
3779
+ if (AcceptBlock (pblock , state, chainparams, NULL , true , dbp, NULL ))
3777
3780
nLoaded++;
3778
3781
if (state.IsError ())
3779
3782
break ;
@@ -3800,16 +3803,17 @@ bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskB
3800
3803
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range (head);
3801
3804
while (range.first != range.second ) {
3802
3805
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first ;
3803
- if (ReadBlockFromDisk (block, it->second , chainparams.GetConsensus ()))
3806
+ std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBlock>();
3807
+ if (ReadBlockFromDisk (*pblockrecursive, it->second , chainparams.GetConsensus ()))
3804
3808
{
3805
- LogPrint (" reindex" , " %s: Processing out of order child %s of %s\n " , __func__, block. GetHash ().ToString (),
3809
+ LogPrint (" reindex" , " %s: Processing out of order child %s of %s\n " , __func__, pblockrecursive-> GetHash ().ToString (),
3806
3810
head.ToString ());
3807
3811
LOCK (cs_main);
3808
3812
CValidationState dummy;
3809
- if (AcceptBlock (block , dummy, chainparams, NULL , true , &it->second , NULL ))
3813
+ if (AcceptBlock (pblockrecursive , dummy, chainparams, NULL , true , &it->second , NULL ))
3810
3814
{
3811
3815
nLoaded++;
3812
- queue.push_back (block. GetHash ());
3816
+ queue.push_back (pblockrecursive-> GetHash ());
3813
3817
}
3814
3818
}
3815
3819
range.first ++;
0 commit comments