added get_block_header issue #262
This commit is contained in:
parent
342c8a2976
commit
0aae0ea40c
2 changed files with 28 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
|||
|
||||
// Blocks and transactions
|
||||
optional<block_header> get_block_header(uint32_t block_num)const;
|
||||
map<uint32_t,block_header> get_block_header_batch(const vector<uint32_t> block_num)const;
|
||||
optional<signed_block> get_block(uint32_t block_num)const;
|
||||
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
|
||||
|
||||
|
|
@ -362,6 +363,24 @@ optional<block_header> database_api_impl::get_block_header(uint32_t block_num) c
|
|||
return *result;
|
||||
return {};
|
||||
}
|
||||
map<uint32_t,block_header> database_api::get_block_header_batch(const vector<uint32_t> block_num)const
|
||||
{
|
||||
return my->get_block_header_batch( block_num );
|
||||
}
|
||||
|
||||
map<uint32_t,block_header> database_api_impl::get_block_header_batch(const vector<uint32_t> block_num) const
|
||||
{
|
||||
map<uint32_t,block_header> results;
|
||||
for (const uint32_t& i : block_num) {
|
||||
auto result = _db.fetch_block_by_number(i);
|
||||
if (result)
|
||||
results[i] = *result;
|
||||
else
|
||||
results[i] = {};
|
||||
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
optional<signed_block> database_api::get_block(uint32_t block_num)const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,6 +158,14 @@ class database_api
|
|||
*/
|
||||
optional<block_header> get_block_header(uint32_t block_num)const;
|
||||
|
||||
/**
|
||||
* @brief Retrieve multiple block header by block numbers
|
||||
* @param block_num vector containing heights of the block whose header should be returned
|
||||
* @return array of headers of the referenced blocks, or null if no matching block was found
|
||||
*/
|
||||
map<uint32_t,block_header> get_block_header_batch(const vector<uint32_t> block_num)const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve a full, signed block
|
||||
* @param block_num Height of the block to be returned
|
||||
|
|
@ -588,6 +596,7 @@ FC_API(graphene::app::database_api,
|
|||
|
||||
// Blocks and transactions
|
||||
(get_block_header)
|
||||
(get_block_header_batch)
|
||||
(get_block)
|
||||
(get_transaction)
|
||||
(get_recent_transaction_by_id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue