| 1103 | } |
| 1104 | |
| 1105 | bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams) |
| 1106 | { |
| 1107 | block.SetNull(); |
| 1108 | |
| 1109 | // Open history file to read |
| 1110 | CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); |
| 1111 | if (filein.IsNull()) |
| 1112 | return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString()); |
| 1113 | |
| 1114 | // Read block |
| 1115 | try { |
| 1116 | filein >> block; |
| 1117 | } |
| 1118 | catch (const std::exception& e) { |
| 1119 | return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString()); |
| 1120 | } |
| 1121 | |
| 1122 | // Check Equihash solution |
| 1123 | bool postfork = block.nHeight >= (uint32_t)consensusParams.BTGHeight; |
| 1124 | if (postfork && !CheckEquihashSolution(&block, Params())) { |
| 1125 | return error("ReadBlockFromDisk: Errors in block header at %s (bad Equihash solution)", pos.ToString()); |
| 1126 | } |
| 1127 | // Check the header |
| 1128 | if (!CheckProofOfWork(block.GetHash(), block.nBits, postfork, consensusParams)) |
| 1129 | return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); |
| 1130 | |
| 1131 | return true; |
| 1132 | } |
| 1133 | |
| 1134 | bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams) |
| 1135 | { |
no test coverage detected