Merge branch 'feature/add-get-blocks' into 'develop'
Feature/add get blocks See merge request PBSA/peerplays!18
This commit is contained in:
commit
ec464694a4
5 changed files with 33 additions and 1 deletions
|
|
@ -141,7 +141,7 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
|
vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
|
||||||
{
|
{
|
||||||
FC_ASSERT( block_num_to >= block_num_from );
|
FC_ASSERT( block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100");
|
||||||
vector<optional<signed_block>> res;
|
vector<optional<signed_block>> res;
|
||||||
for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
|
for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
|
||||||
res.push_back(_db.fetch_block_by_number(block_num));
|
res.push_back(_db.fetch_block_by_number(block_num));
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
||||||
optional<block_header> get_block_header(uint32_t block_num)const;
|
optional<block_header> get_block_header(uint32_t block_num)const;
|
||||||
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums)const;
|
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums)const;
|
||||||
optional<signed_block> get_block(uint32_t block_num)const;
|
optional<signed_block> get_block(uint32_t block_num)const;
|
||||||
|
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
|
||||||
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
|
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
|
|
@ -499,6 +500,21 @@ optional<signed_block> database_api_impl::get_block(uint32_t block_num)const
|
||||||
return _db.fetch_block_by_number(block_num);
|
return _db.fetch_block_by_number(block_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<optional<signed_block>> database_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
|
||||||
|
{
|
||||||
|
return my->get_blocks( block_num_from, block_num_to );
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<optional<signed_block>> database_api_impl::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const
|
||||||
|
{
|
||||||
|
FC_ASSERT( block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100");
|
||||||
|
vector<optional<signed_block>> res;
|
||||||
|
for(uint32_t block_num=block_num_from; block_num<=block_num_to; block_num++) {
|
||||||
|
res.push_back(_db.fetch_block_by_number(block_num));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
processed_transaction database_api::get_transaction( uint32_t block_num, uint32_t trx_in_block )const
|
processed_transaction database_api::get_transaction( uint32_t block_num, uint32_t trx_in_block )const
|
||||||
{
|
{
|
||||||
return my->get_transaction( block_num, trx_in_block );
|
return my->get_transaction( block_num, trx_in_block );
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,14 @@ class database_api
|
||||||
*/
|
*/
|
||||||
optional<signed_block> get_block(uint32_t block_num)const;
|
optional<signed_block> get_block(uint32_t block_num)const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieve a list of signed blocks
|
||||||
|
* @param block_num_from start
|
||||||
|
* @param block_num_to end
|
||||||
|
* @return list of referenced blocks
|
||||||
|
*/
|
||||||
|
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief used to fetch an individual transaction.
|
* @brief used to fetch an individual transaction.
|
||||||
*/
|
*/
|
||||||
|
|
@ -985,6 +993,7 @@ FC_API(graphene::app::database_api,
|
||||||
(get_block_header)
|
(get_block_header)
|
||||||
(get_block_header_batch)
|
(get_block_header_batch)
|
||||||
(get_block)
|
(get_block)
|
||||||
|
(get_blocks)
|
||||||
(get_transaction)
|
(get_transaction)
|
||||||
(get_recent_transaction_by_id)
|
(get_recent_transaction_by_id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,7 @@ class wallet_api
|
||||||
*/
|
*/
|
||||||
variant_object about() const;
|
variant_object about() const;
|
||||||
optional<signed_block_with_info> get_block( uint32_t num );
|
optional<signed_block_with_info> get_block( uint32_t num );
|
||||||
|
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const;
|
||||||
/** Returns the number of accounts registered on the blockchain
|
/** Returns the number of accounts registered on the blockchain
|
||||||
* @returns the number of registered accounts
|
* @returns the number of registered accounts
|
||||||
*/
|
*/
|
||||||
|
|
@ -2652,6 +2653,7 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(get_account)
|
(get_account)
|
||||||
(get_account_id)
|
(get_account_id)
|
||||||
(get_block)
|
(get_block)
|
||||||
|
(get_blocks)
|
||||||
(get_account_count)
|
(get_account_count)
|
||||||
(get_account_history)
|
(get_account_history)
|
||||||
(get_relative_account_history)
|
(get_relative_account_history)
|
||||||
|
|
|
||||||
|
|
@ -4351,6 +4351,11 @@ optional<signed_block_with_info> wallet_api::get_block(uint32_t num)
|
||||||
return my->_remote_db->get_block(num);
|
return my->_remote_db->get_block(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<optional<signed_block>> wallet_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const
|
||||||
|
{
|
||||||
|
return my->_remote_db->get_blocks(block_num_from, block_num_to);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t wallet_api::get_account_count() const
|
uint64_t wallet_api::get_account_count() const
|
||||||
{
|
{
|
||||||
return my->_remote_db->get_account_count();
|
return my->_remote_db->get_account_count();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue