| 1845 | // |
| 1846 | |
| 1847 | bool WriteBlockToDisk(const CBlock& block, CDiskBlockPos& pos) |
| 1848 | { |
| 1849 | // Open history file to append |
| 1850 | CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); |
| 1851 | if (fileout.IsNull()) |
| 1852 | return error("WriteBlockToDisk : OpenBlockFile failed"); |
| 1853 | |
| 1854 | // Write index header |
| 1855 | unsigned int nSize = fileout.GetSerializeSize(block); |
| 1856 | fileout << FLATDATA(Params().MessageStart()) << nSize; |
| 1857 | |
| 1858 | // Write block |
| 1859 | long fileOutPos = ftell(fileout.Get()); |
| 1860 | if (fileOutPos < 0) |
| 1861 | return error("WriteBlockToDisk : ftell failed"); |
| 1862 | |
| 1863 | pos.nPos = (unsigned int)fileOutPos; |
| 1864 | fileout << block; |
| 1865 | |
| 1866 | return true; |
| 1867 | } |
| 1868 | |
| 1869 | bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, int nHeight, const Consensus::Params& consensusParams, bool required) |
| 1870 | { |
no test coverage detected