| 702 | } |
| 703 | |
| 704 | static bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessageHeader::MessageStartChars& messageStart) |
| 705 | { |
| 706 | // Open history file to append |
| 707 | CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); |
| 708 | if (fileout.IsNull()) |
| 709 | return error("WriteBlockToDisk: OpenBlockFile failed"); |
| 710 | |
| 711 | // Write index header |
| 712 | unsigned int nSize = GetSerializeSize(block, fileout.GetVersion()); |
| 713 | fileout << messageStart << nSize; |
| 714 | |
| 715 | // Write block |
| 716 | long fileOutPos = ftell(fileout.Get()); |
| 717 | if (fileOutPos < 0) |
| 718 | return error("WriteBlockToDisk: ftell failed"); |
| 719 | pos.nPos = (unsigned int)fileOutPos; |
| 720 | fileout << block; |
| 721 | |
| 722 | return true; |
| 723 | } |
| 724 | |
| 725 | bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValidationState& state, CBlockIndex* pindex, const CChainParams& chainparams) |
| 726 | { |
no test coverage detected