| 47 | } |
| 48 | |
| 49 | int initializeRecordingFile(Blockchain &chain) { |
| 50 | auto mempoolDir = chain.getAccess().config.mempoolDirectory(); |
| 51 | if (!mempoolDir.exists()){ |
| 52 | filesystem::create_directory(mempoolDir); |
| 53 | } |
| 54 | auto mostRecentBlock = chain[static_cast<int>(chain.size()) - 1]; |
| 55 | FixedSizeFileWriter<uint32_t> txIndexFile(chain.getAccess().config.mempoolDirectory()/"tx_index"); |
| 56 | auto fileNum = static_cast<int>(txIndexFile.size()); |
| 57 | txIndexFile.write(mostRecentBlock.endTxIndex()); |
| 58 | FixedSizeFileWriter<int32_t> blockIndexFile(chain.getAccess().config.mempoolDirectory()/"block_index"); |
| 59 | assert(static_cast<int>(blockIndexFile.size()) == fileNum); |
| 60 | blockIndexFile.write(mostRecentBlock.height() + 1); |
| 61 | return fileNum; |
| 62 | } |
| 63 | |
| 64 | struct MempoolFiles { |
| 65 | FixedSizeFileWriter<MempoolRecord> txTimeFile; |
no test coverage detected