MCPcopy Create free account
hub / github.com/bcndev/bytecoin / load_offsets

Method load_offsets

src/Core/BlockChainFileFormat.cpp:53–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void LegacyBlockChainReader::load_offsets() {
54 if (m_count == 0 || !m_offsets.empty())
55 return;
56 uint64_t pos = 0;
57 try {
58 m_items_file->seek(0, SEEK_END);
59 uint64_t m_itemsFileSize = m_items_file->tellp();
60 std::vector<uint32_t> item_sizes(m_count);
61 m_indexes_file->read(reinterpret_cast<char *>(item_sizes.data()), m_count * sizeof(uint32_t));
62 for (size_t i = 0; i < item_sizes.size(); ++i) {
63 m_offsets.emplace_back(pos);
64 pos += item_sizes[i];
65 if (pos > m_itemsFileSize) // index offset outside item file
66 return;
67 }
68 } catch (const std::runtime_error &) {
69 }
70 m_offsets.emplace_back(pos);
71}
72
73BinaryArray LegacyBlockChainReader::get_block_data_by_index(Height i) {
74 load_offsets();

Callers

nothing calls this directly

Calls 6

seekMethod · 0.80
tellpMethod · 0.80
emptyMethod · 0.45
readMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected