| 1082 | // |
| 1083 | |
| 1084 | static bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart) |
| 1085 | { |
| 1086 | // Open history file to append |
| 1087 | CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); |
| 1088 | if (fileout.IsNull()) |
| 1089 | return error("WriteBlockToDisk: OpenBlockFile failed"); |
| 1090 | |
| 1091 | // Write index header |
| 1092 | unsigned int nSize = GetSerializeSize(fileout, block); |
| 1093 | fileout << messageStart << nSize; |
| 1094 | |
| 1095 | // Write block |
| 1096 | long fileOutPos = ftell(fileout.Get()); |
| 1097 | if (fileOutPos < 0) |
| 1098 | return error("WriteBlockToDisk: ftell failed"); |
| 1099 | pos.nPos = (unsigned int)fileOutPos; |
| 1100 | fileout << block; |
| 1101 | |
| 1102 | return true; |
| 1103 | } |
| 1104 | |
| 1105 | bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams) |
| 1106 | { |
no test coverage detected