MCPcopy Create free account
hub / github.com/bitshares/bitshares-core / fetch_block_id

Method fetch_block_id

libraries/chain/block_database.cpp:136–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136block_id_type block_database::fetch_block_id( uint32_t block_num )const
137{
138 assert( block_num != 0 );
139 index_entry e;
140 int64_t index_pos = sizeof(e) * int64_t(block_num);
141 _block_num_to_pos.seekg( 0, _block_num_to_pos.end );
142 if ( _block_num_to_pos.tellg() <= index_pos )
143 FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num));
144
145 _block_num_to_pos.seekg( index_pos );
146 _block_num_to_pos.read( (char*)&e, sizeof(e) );
147
148 FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" );
149 return e.block_id;
150}
151
152optional<signed_block> block_database::fetch_optional( const block_id_type& id )const
153{

Callers 1

db_block.cppFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected