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

Method get_block_data_by_index

src/Core/BlockChainFileFormat.cpp:73–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73BinaryArray 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
88const size_t MAX_PRELOAD_BLOCKS = 100;
89// const size_t MAX_PRELOAD_TOTAL_SIZE = 50 * 1024 * 1024;

Callers

nothing calls this directly

Calls 5

atMethod · 0.80
seekMethod · 0.80
sizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected