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

Add a way to query nodeos reversible db size - added an api endpoint … #8609

Merged
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
2 changes: 2 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,8 @@ chainbase::database& controller::mutable_db()const { return my->db; }

const fork_database& controller::fork_db()const { return my->fork_db; }

const chainbase::database& controller::reversible_db()const { return my->reversible_blocks; }

void controller::preactivate_feature( const digest_type& feature_digest ) {
const auto& pfs = my->protocol_features.get_protocol_feature_set();
auto cur_time = pending_block_time();
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 @@ -171,6 +171,7 @@ namespace eosio { namespace chain {
boost::asio::io_context& get_thread_pool();

const chainbase::database& db()const;
const chainbase::database& reversible_db() const;

const fork_database& fork_db()const;

Expand Down
13 changes: 11 additions & 2 deletions plugins/db_size_api_plugin/db_size_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ void db_size_api_plugin::plugin_startup() {
app().get_plugin<http_plugin>().add_api({
CALL(db_size, this, get,
INVOKE_R_V(this, get), 200),
CALL(db_size, this, get_reversible,
INVOKE_R_V(this, get_reversible), 200),
});
}

db_size_stats db_size_api_plugin::get() {
const chainbase::database& db = app().get_plugin<chain_plugin>().chain().db();
db_size_stats db_size_api_plugin::get_db_stats(const chainbase::database& db) {
db_size_stats ret;

ret.free_bytes = db.get_segment_manager()->get_free_memory();
Expand All @@ -46,6 +47,14 @@ db_size_stats db_size_api_plugin::get() {
return ret;
}

db_size_stats db_size_api_plugin::get() {
return get_db_stats(app().get_plugin<chain_plugin>().chain().db());
}

db_size_stats db_size_api_plugin::get_reversible() {
return get_db_stats(app().get_plugin<chain_plugin>().chain().reversible_db());
}

#undef INVOKE_R_V
#undef CALL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class db_size_api_plugin : public plugin<db_size_api_plugin> {
void plugin_shutdown() {}

db_size_stats get();
db_size_stats get_reversible();

private:
db_size_stats get_db_stats(const chainbase::database& );
};

}
Expand Down