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

2.0.x -- Add total CPU and NET to get_info #10932

Merged
merged 1 commit into from
Jan 3, 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
3 changes: 3 additions & 0 deletions libraries/chain/include/eosio/chain/resource_limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ namespace eosio { namespace chain { namespace resource_limits {
void process_block_usage( uint32_t block_num );

// accessors
uint64_t get_total_cpu_weight() const;
uint64_t get_total_net_weight() const;

uint64_t get_virtual_block_cpu_limit() const;
uint64_t get_virtual_block_net_limit() const;

Expand Down
10 changes: 10 additions & 0 deletions libraries/chain/resource_limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,16 @@ void resource_limits_manager::process_block_usage(uint32_t block_num) {

}

uint64_t resource_limits_manager::get_total_cpu_weight() const {
const auto& state = _db.get<resource_limits_state_object>();
return state.total_cpu_weight;
}

uint64_t resource_limits_manager::get_total_net_weight() const {
const auto& state = _db.get<resource_limits_state_object>();
return state.total_net_weight;
}

uint64_t resource_limits_manager::get_virtual_block_cpu_limit() const {
const auto& state = _db.get<resource_limits_state_object>();
return state.virtual_cpu_limit;
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 @@ -1537,7 +1537,9 @@ read_only::get_info_results read_only::get_info(const read_only::get_info_params
app().version_string(),
db.fork_db_pending_head_block_num(),
db.fork_db_pending_head_block_id(),
app().full_version_string()
app().full_version_string(),
rm.get_total_cpu_weight(),
rm.get_total_net_weight()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class read_only {
optional<uint32_t> fork_db_head_block_num;
optional<chain::block_id_type> fork_db_head_block_id;
optional<string> server_full_version_string;
optional<uint64_t> total_cpu_weight;
optional<uint64_t> total_net_weight;
};
get_info_results get_info(const get_info_params&) const;

Expand Down Expand Up @@ -773,7 +775,7 @@ FC_REFLECT(eosio::chain_apis::read_only::get_info_results,
(server_version)(chain_id)(head_block_num)(last_irreversible_block_num)(last_irreversible_block_id)
(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) )
(server_version_string)(fork_db_head_block_num)(fork_db_head_block_id)(server_full_version_string)(total_cpu_weight)(total_net_weight) )
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