Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

add first_block_num for get_info command #10087

Merged
merged 4 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/chain/block_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ namespace eosio { namespace chain {

void block_log::set_version(uint32_t ver) { detail::block_log_impl::default_version = ver; }
uint32_t block_log::version() const { return my->preamble.version; }
uint32_t block_log::get_first_block_num() const { return my->preamble.first_block_num; }

detail::block_log_impl::block_log_impl(const block_log::config_type& config)
: stride( config.stride )
Expand Down
6 changes: 6 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,11 @@ const controller::config& controller::get_config()const
return my->conf;
}

uint32_t controller::get_first_block_num()const
{
return my->blog.get_first_block_num();
}

controller::controller( const controller::config& cfg, const chain_id_type& chain_id )
:my( new controller_impl( cfg, *this, protocol_feature_set{}, chain_id ) )
{
Expand Down Expand Up @@ -2801,6 +2806,7 @@ block_state_ptr controller::fetch_block_state_by_id( block_id_type id )const {

block_state_ptr controller::fetch_block_state_by_number( uint32_t block_num )const { try {
const auto& rev_blocks = my->reversible_blocks.get_index<reversible_block_index,by_num>();

auto objitr = rev_blocks.find(block_num);

if( objitr == rev_blocks.end() ) {
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/block_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace eosio { namespace chain {
// used for unit test to generate older version blocklog
static void set_version(uint32_t);
uint32_t version() const;
uint32_t get_first_block_num() const;

/**
* @param n Only test 1 block out of every n blocks. If n is 0, it is maximum between 1 and the ceiling of the total number blocks divided by 8.
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ namespace eosio { namespace chain {
const protocol_feature_manager& get_protocol_feature_manager()const;
uint32_t get_max_nonprivileged_inline_action_size()const;
const config& get_config()const;
uint32_t get_first_block_num() const;

const flat_set<account_name>& get_actor_whitelist() const;
const flat_set<account_name>& get_actor_blacklist() const;
Expand Down
4 changes: 3 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ std::string itoh(I n, size_t hlen = sizeof(I)<<1) {
}

read_only::get_info_results read_only::get_info(const read_only::get_info_params&) const {

const auto& rm = db.get_resource_limits_manager();
return {
itoh(static_cast<uint32_t>(app().version())),
Expand All @@ -1725,7 +1726,8 @@ read_only::get_info_results read_only::get_info(const read_only::get_info_params
db.fork_db_pending_head_block_num(),
db.fork_db_pending_head_block_id(),
app().full_version_string(),
db.last_irreversible_block_time()
db.last_irreversible_block_time(),
db.get_first_block_num()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class read_only {
std::optional<chain::block_id_type> fork_db_head_block_id;
std::optional<string> server_full_version_string;
std::optional<fc::time_point> last_irreversible_block_time;
std::optional<uint32_t> first_block_num;
};
get_info_results get_info(const get_info_params&) const;

Expand Down Expand Up @@ -1084,7 +1085,7 @@ FC_REFLECT(eosio::chain_apis::read_only::get_info_results,
(head_block_id)(head_block_time)(head_block_producer)
(virtual_block_cpu_limit)(virtual_block_net_limit)(block_cpu_limit)(block_net_limit)
(server_version_string)(fork_db_head_block_num)(fork_db_head_block_id)(server_full_version_string)
(last_irreversible_block_time) )
(last_irreversible_block_time) (first_block_num) )
FC_REFLECT(eosio::chain_apis::read_only::get_activated_protocol_features_params, (lower_bound)(upper_bound)(limit)(search_by_block_num)(reverse) )
FC_REFLECT(eosio::chain_apis::read_only::get_activated_protocol_features_results, (activated_protocol_features)(more) )
FC_REFLECT(eosio::chain_apis::read_only::get_block_params, (block_num_or_id))
Expand Down