Skip to content

Commit

Permalink
Debug rejectreason
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Dec 30, 2015
1 parent 43560b9 commit cea9194
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,16 @@ bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHea
if (fileOutPos < 0)
return error("WriteBlockToDisk: ftell failed");
pos.nPos = (unsigned int)fileOutPos;
fileout << block;
try {
fileout << block;
}
catch (const std::exception& e) {
return error("%s: Serialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
}

CValidationState s;
if (!CheckBlock(block, s))
return error("WriteBlockToDisk: check error %s", s.GetRejectReason());

return true;
}
Expand All @@ -1351,6 +1360,10 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus:
if (!CheckProofOfWork(block.GetHash(), block.nBits, consensusParams))
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());

CValidationState s;
if (!CheckBlock(block, s))
return error("ReadBlockFromDisk: check error %s", s.GetRejectReason());

return true;
}

Expand Down Expand Up @@ -2953,6 +2966,11 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo

// Check the merkle root.
if (fCheckMerkleRoot) {
LogPrintf("Checking block %s: merkle root %s\n", block.GetHash().ToString(), block.hashMerkleRoot.ToString());
for (unsigned int i = 0; i < block.vtx.size(); i++) {
LogPrintf(" * Transaction %i hash=%s whash=%s:\n", i, block.vtx[i].GetHash().ToString(), block.vtx[i].GetWitnessHash().ToString());
LogPrintf(" * tx = %s\n", block.vtx[i].ToString());
}
bool mutated;
uint256 hashMerkleRoot2 = BlockMerkleRoot(block, &mutated);
if (block.hashMerkleRoot != hashMerkleRoot2)
Expand Down

0 comments on commit cea9194

Please sign in to comment.