| 1584 | } |
| 1585 | |
| 1586 | bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos) |
| 1587 | { |
| 1588 | block.SetNull(); |
| 1589 | |
| 1590 | // Open history file to read |
| 1591 | CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); |
| 1592 | if (filein.IsNull()) |
| 1593 | return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString()); |
| 1594 | |
| 1595 | // Read block |
| 1596 | try { |
| 1597 | filein >> block; |
| 1598 | } |
| 1599 | catch (const std::exception& e) { |
| 1600 | return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString()); |
| 1601 | } |
| 1602 | |
| 1603 | // Check the header |
| 1604 | if (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) |
| 1605 | return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); |
| 1606 | |
| 1607 | return true; |
| 1608 | } |
| 1609 | |
| 1610 | bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex) |
| 1611 | { |
no test coverage detected