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 📦 #11013

Merged
merged 3 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -570,6 +570,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
5 changes: 5 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,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
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 @@ -206,6 +206,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 @@ -1485,6 +1485,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 @@ -1507,7 +1508,8 @@ read_only::get_info_results read_only::get_info(const read_only::get_info_params
app().full_version_string(),
db.last_irreversible_block_time(),
rm.get_total_cpu_weight(),
rm.get_total_net_weight()
rm.get_total_net_weight(),
db.get_first_block_num()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class read_only {
std::optional<fc::time_point> last_irreversible_block_time;
std::optional<uint64_t> total_cpu_weight;
std::optional<uint64_t> total_net_weight;
std::optional<uint32_t> first_block_num;
};
get_info_results get_info(const get_info_params&) const;

Expand Down Expand Up @@ -1108,7 +1109,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)(total_cpu_weight)(total_net_weight) )
(last_irreversible_block_time)(total_cpu_weight)(total_net_weight)(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