| 753 | } |
| 754 | |
| 755 | bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos, const Consensus::Params& consensusParams) |
| 756 | { |
| 757 | block.SetNull(); |
| 758 | |
| 759 | // Open history file to read |
| 760 | CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); |
| 761 | if (filein.IsNull()) |
| 762 | return error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString()); |
| 763 | |
| 764 | // Read block |
| 765 | try { |
| 766 | filein >> block; |
| 767 | } |
| 768 | catch (const std::exception& e) { |
| 769 | return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString()); |
| 770 | } |
| 771 | |
| 772 | // Check the header |
| 773 | const uint256 block_hash = block.GetHash(); |
| 774 | if (block_hash != consensusParams.hashGenesisBlock && |
| 775 | !CheckProof(block, consensusParams)) { |
| 776 | return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); |
| 777 | } |
| 778 | |
| 779 | // Signet only: check block solution |
| 780 | if (consensusParams.signet_blocks && !CheckSignetBlockSolution(block, consensusParams)) { |
| 781 | return error("ReadBlockFromDisk: Errors in block solution at %s", pos.ToString()); |
| 782 | } |
| 783 | |
| 784 | return true; |
| 785 | } |
| 786 | |
| 787 | bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams) |
| 788 | { |