| 71 | } |
| 72 | |
| 73 | BinaryArray LegacyBlockChainReader::get_block_data_by_index(Height i) { |
| 74 | load_offsets(); |
| 75 | if (i + 1 >= m_offsets.size()) |
| 76 | return BinaryArray{}; |
| 77 | try { |
| 78 | size_t si = common::integer_cast<size_t>(m_offsets.at(i + 1) - m_offsets.at(i)); |
| 79 | m_items_file->seek(m_offsets.at(i), SEEK_SET); |
| 80 | BinaryArray data_cache(si); |
| 81 | m_items_file->read(reinterpret_cast<char *>(data_cache.data()), si); |
| 82 | return data_cache; |
| 83 | } catch (const std::runtime_error &) { |
| 84 | return BinaryArray{}; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | const size_t MAX_PRELOAD_BLOCKS = 100; |
| 89 | // const size_t MAX_PRELOAD_TOTAL_SIZE = 50 * 1024 * 1024; |