| 22 | const bool multicore = true; |
| 23 | |
| 24 | LegacyBlockChainReader::LegacyBlockChainReader(const Currency ¤cy, |
| 25 | const std::string &index_file_name, |
| 26 | const std::string &item_file_name) |
| 27 | : m_currency(currency) { |
| 28 | try { |
| 29 | m_indexes_file = std::make_unique<platform::FileStream>(index_file_name, platform::O_READ_EXISTING); |
| 30 | m_items_file = std::make_unique<platform::FileStream>(item_file_name, platform::O_READ_EXISTING); |
| 31 | |
| 32 | m_indexes_file->seek(0, SEEK_END); |
| 33 | uint64_t m_indexesFileSize = m_indexes_file->tellp(); |
| 34 | m_indexes_file->seek(0, SEEK_SET); |
| 35 | uint64_t max_hei = (m_indexesFileSize - sizeof(uint64_t)) / sizeof(uint32_t); |
| 36 | uint64_t read_hei = 0; |
| 37 | m_indexes_file->read(reinterpret_cast<char *>(&read_hei), sizeof(uint64_t)); |
| 38 | m_count = common::integer_cast<Height>(std::min(read_hei, max_hei)); |
| 39 | } catch (const std::runtime_error &) { |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | LegacyBlockChainReader::~LegacyBlockChainReader() { |
| 44 | { |