Cli debug online weight (#1744)

* cli for debugging online_weights table

* formatting

* drop clear, already a part of cli.cpp
formatting
verbiage update

* stringify timestamps
This commit is contained in:
Russel Waters 2019-02-18 14:05:16 -05:00 committed by GitHub
commit d3f3459339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,7 @@ int main (int argc, char * const * argv)
("batch_size",boost::program_options::value<std::size_t> (), "Increase sideband batch size, default 512")
("debug_block_count", "Display the number of block")
("debug_bootstrap_generate", "Generate bootstrap sequence of blocks")
("debug_dump_online_weight", "Dump online_weights table")
("debug_dump_representatives", "List representatives and weights")
("debug_account_count", "Display the number of accounts")
("debug_mass_activity", "Generates fake debug activity")
@ -165,6 +166,22 @@ int main (int argc, char * const * argv)
result = -1;
}
}
else if (vm.count ("debug_dump_online_weight"))
{
nano::inactive_node node (data_path);
auto current (node.node->online_reps.online_stake ());
std::cout << boost::str (boost::format ("Online Weight %1%\n") % current);
auto transaction (node.node->store.tx_begin_read ());
for (auto i (node.node->store.online_weight_begin (transaction)), n (node.node->store.online_weight_end ()); i != n; ++i)
{
using time_point = std::chrono::system_clock::time_point;
time_point ts (std::chrono::duration_cast<time_point::duration> (std::chrono::nanoseconds (i->first)));
std::time_t timestamp = std::chrono::system_clock::to_time_t (ts);
std::string weight;
i->second.encode_dec (weight);
std::cout << boost::str (boost::format ("Timestamp %1% Weight %2%\n") % ctime (&timestamp) % weight);
}
}
else if (vm.count ("debug_dump_representatives"))
{
nano::inactive_node node (data_path);