|
|
|
@ -627,7 +627,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
@@ -627,7 +627,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
|
|
|
|
|
if (pcoinsTip->GetCoins(GetHash(), coins)) { |
|
|
|
|
CBlockIndex *pindex = FindBlockByHeight(coins.nHeight); |
|
|
|
|
if (pindex) { |
|
|
|
|
if (!blockTmp.ReadFromDisk(pindex)) |
|
|
|
|
if (!ReadBlockFromDisk(blockTmp, pindex)) |
|
|
|
|
return 0; |
|
|
|
|
pblock = &blockTmp; |
|
|
|
|
} |
|
|
|
@ -1114,7 +1114,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
@@ -1114,7 +1114,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|
|
|
|
|
|
|
|
|
if (pindexSlow) { |
|
|
|
|
CBlock block; |
|
|
|
|
if (block.ReadFromDisk(pindexSlow)) { |
|
|
|
|
if (ReadBlockFromDisk(block, pindexSlow)) { |
|
|
|
|
BOOST_FOREACH(const CTransaction &tx, block.vtx) { |
|
|
|
|
if (tx.GetHash() == hash) { |
|
|
|
|
txOut = tx; |
|
|
|
@ -1172,12 +1172,12 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
@@ -1172,12 +1172,12 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CBlock::ReadFromDisk(const CBlockIndex* pindex) |
|
|
|
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex) |
|
|
|
|
{ |
|
|
|
|
if (!ReadFromDisk(pindex->GetBlockPos())) |
|
|
|
|
if (!ReadBlockFromDisk(block, pindex->GetBlockPos())) |
|
|
|
|
return false; |
|
|
|
|
if (GetHash() != pindex->GetBlockHash()) |
|
|
|
|
return error("CBlock::ReadFromDisk() : GetHash() doesn't match index"); |
|
|
|
|
if (block.GetHash() != pindex->GetBlockHash()) |
|
|
|
|
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*) : GetHash() doesn't match index"); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1886,7 +1886,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
@@ -1886,7 +1886,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
vector<CTransaction> vResurrect; |
|
|
|
|
BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) { |
|
|
|
|
CBlock block; |
|
|
|
|
if (!block.ReadFromDisk(pindex)) |
|
|
|
|
if (!ReadBlockFromDisk(block, pindex)) |
|
|
|
|
return state.Abort(_("Failed to read block")); |
|
|
|
|
int64 nStart = GetTimeMicros(); |
|
|
|
|
if (!block.DisconnectBlock(state, pindex, view)) |
|
|
|
@ -1906,7 +1906,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
@@ -1906,7 +1906,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
vector<CTransaction> vDelete; |
|
|
|
|
BOOST_FOREACH(CBlockIndex *pindex, vConnect) { |
|
|
|
|
CBlock block; |
|
|
|
|
if (!block.ReadFromDisk(pindex)) |
|
|
|
|
if (!ReadBlockFromDisk(block, pindex)) |
|
|
|
|
return state.Abort(_("Failed to read block")); |
|
|
|
|
int64 nStart = GetTimeMicros(); |
|
|
|
|
if (!block.ConnectBlock(state, pindex, view)) { |
|
|
|
@ -2736,8 +2736,8 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
@@ -2736,8 +2736,8 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
|
|
|
|
|
break; |
|
|
|
|
CBlock block; |
|
|
|
|
// check level 0: read from disk
|
|
|
|
|
if (!block.ReadFromDisk(pindex)) |
|
|
|
|
return error("VerifyDB() : *** block.ReadFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
|
if (!ReadBlockFromDisk(block, pindex)) |
|
|
|
|
return error("VerifyDB() : *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
|
// check level 1: verify block validity
|
|
|
|
|
if (nCheckLevel >= 1 && !block.CheckBlock(state)) |
|
|
|
|
return error("VerifyDB() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
@ -2773,8 +2773,8 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
@@ -2773,8 +2773,8 @@ bool VerifyDB(int nCheckLevel, int nCheckDepth)
|
|
|
|
|
boost::this_thread::interruption_point(); |
|
|
|
|
pindex = pindex->GetNextInMainChain(); |
|
|
|
|
CBlock block; |
|
|
|
|
if (!block.ReadFromDisk(pindex)) |
|
|
|
|
return error("VerifyDB() : *** block.ReadFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
|
if (!ReadBlockFromDisk(block, pindex)) |
|
|
|
|
return error("VerifyDB() : *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
|
if (!block.ConnectBlock(state, pindex, coins)) |
|
|
|
|
return error("VerifyDB() : *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); |
|
|
|
|
} |
|
|
|
@ -2884,7 +2884,7 @@ void PrintBlockTree()
@@ -2884,7 +2884,7 @@ void PrintBlockTree()
|
|
|
|
|
|
|
|
|
|
// print item
|
|
|
|
|
CBlock block; |
|
|
|
|
block.ReadFromDisk(pindex); |
|
|
|
|
ReadBlockFromDisk(block, pindex); |
|
|
|
|
printf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"", |
|
|
|
|
pindex->nHeight, |
|
|
|
|
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos, |
|
|
|
@ -3108,7 +3108,7 @@ void static ProcessGetData(CNode* pfrom)
@@ -3108,7 +3108,7 @@ void static ProcessGetData(CNode* pfrom)
|
|
|
|
|
if (mi != mapBlockIndex.end()) |
|
|
|
|
{ |
|
|
|
|
CBlock block; |
|
|
|
|
block.ReadFromDisk((*mi).second); |
|
|
|
|
ReadBlockFromDisk(block, (*mi).second); |
|
|
|
|
if (inv.type == MSG_BLOCK) |
|
|
|
|
pfrom->PushMessage("block", block); |
|
|
|
|
else // MSG_FILTERED_BLOCK)
|
|
|
|
|