Add uncemented frontier output CLI command (#2777)
* Add uncemented diagnostic CLI & RPC commands * Add optional only_unconfirmed_frontiers flag to new RPC call * Double bandwidth limit * Remove election_winner_details RPC * Remove to_string() (Serg review) * Update with height delta too and sort them (code from Colin) * Fix build error * Always output when conf height entry doesn't exist (Colin review) * Update description for CLI
This commit is contained in:
parent
185de4e06c
commit
3dc54f78d9
3 changed files with 70 additions and 0 deletions
|
@ -98,6 +98,7 @@ int main (int argc, char * const * argv)
|
|||
("debug_cemented_block_count", "Displays the number of cemented (confirmed) blocks")
|
||||
("debug_stacktrace", "Display an example stacktrace")
|
||||
("debug_account_versions", "Display the total counts of each version for all accounts (including unpocketed)")
|
||||
("debug_unconfirmed_frontiers", "Displays the account, height (sorted), frontier and cemented frontier for all accounts which are not fully confirmed")
|
||||
("validate_blocks,debug_validate_blocks", "Check all blocks for correct hash, signature, work value")
|
||||
("platform", boost::program_options::value<std::string> (), "Defines the <platform> for OpenCL commands")
|
||||
("device", boost::program_options::value<std::string> (), "Defines <device> for OpenCL command")
|
||||
|
@ -1926,6 +1927,22 @@ int main (int argc, char * const * argv)
|
|||
output_account_version_number (i, unopened_account_version_totals[i]);
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_unconfirmed_frontiers"))
|
||||
{
|
||||
auto inactive_node = nano::default_inactive_node (data_path, vm);
|
||||
auto node = inactive_node->node;
|
||||
|
||||
auto unconfirmed_frontiers = node->ledger.unconfirmed_frontiers ();
|
||||
std::cout << "Account: Height delta | Frontier | Confirmed frontier\n";
|
||||
for (auto & unconfirmed_frontier : unconfirmed_frontiers)
|
||||
{
|
||||
auto const & unconfirmed_info = unconfirmed_frontier.second;
|
||||
|
||||
std::cout << (boost::format ("%1%: %2% %3% %4%\n") % unconfirmed_info.account.to_account () % unconfirmed_frontier.first % unconfirmed_info.frontier.to_string () % unconfirmed_info.cemented_frontier.to_string ()).str ();
|
||||
}
|
||||
|
||||
std::cout << "\nNumber of unconfirmed frontiers: " << unconfirmed_frontiers.size () << std::endl;
|
||||
}
|
||||
else if (vm.count ("version"))
|
||||
{
|
||||
std::cout << "Version " << NANO_VERSION_STRING << "\n"
|
||||
|
|
|
@ -1206,6 +1206,48 @@ bool nano::ledger::block_confirmed (nano::transaction const & transaction_a, nan
|
|||
return confirmed;
|
||||
}
|
||||
|
||||
std::multimap<uint64_t, nano::uncemented_info, std::greater<>> nano::ledger::unconfirmed_frontiers () const
|
||||
{
|
||||
std::multimap<uint64_t, nano::uncemented_info, std::greater<>> unconfirmed_frontiers_l;
|
||||
auto transaction (store.tx_begin_read ());
|
||||
auto conf_height_i = store.confirmation_height_begin (transaction);
|
||||
|
||||
for (auto i (store.latest_begin (transaction)), n (store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
// If the confirmation height of an account doesn't exist the iterator will point 1 past it.
|
||||
auto conf_height_info = conf_height_i->second;
|
||||
auto const & account (i->first);
|
||||
auto conf_height_exists = (conf_height_i->first == account);
|
||||
if (!conf_height_exists)
|
||||
{
|
||||
conf_height_info.height = 0;
|
||||
conf_height_info.frontier = 0;
|
||||
}
|
||||
|
||||
auto const & account_info (i->second);
|
||||
if (account_info.block_count != conf_height_info.height)
|
||||
{
|
||||
// Always output as no confirmation height has been set on the account yet
|
||||
auto height_delta = account_info.block_count - conf_height_info.height;
|
||||
auto const & frontier = account_info.head;
|
||||
auto const & cemented_frontier = conf_height_info.frontier;
|
||||
unconfirmed_frontiers_l.emplace (std::piecewise_construct, std::forward_as_tuple (height_delta), std::forward_as_tuple (cemented_frontier, frontier, i->first));
|
||||
}
|
||||
|
||||
if (conf_height_exists)
|
||||
{
|
||||
// Increment the iterator so that it stays in sync with accounts in the account table.
|
||||
++conf_height_i;
|
||||
}
|
||||
}
|
||||
return unconfirmed_frontiers_l;
|
||||
}
|
||||
|
||||
nano::uncemented_info::uncemented_info (nano::block_hash const & cemented_frontier, nano::block_hash const & frontier, nano::account const & account) :
|
||||
cemented_frontier (cemented_frontier), frontier (frontier), account (account)
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<nano::container_info_component> nano::collect_container_info (ledger & ledger, const std::string & name)
|
||||
{
|
||||
auto count = ledger.bootstrap_weights_size.load ();
|
||||
|
|
|
@ -12,6 +12,16 @@ class stat;
|
|||
class write_transaction;
|
||||
|
||||
using tally_t = std::map<nano::uint128_t, std::shared_ptr<nano::block>, std::greater<nano::uint128_t>>;
|
||||
|
||||
class uncemented_info
|
||||
{
|
||||
public:
|
||||
uncemented_info (nano::block_hash const & cemented_frontier, nano::block_hash const & frontier, nano::account const & account);
|
||||
nano::block_hash cemented_frontier;
|
||||
nano::block_hash frontier;
|
||||
nano::account account;
|
||||
};
|
||||
|
||||
class ledger final
|
||||
{
|
||||
public:
|
||||
|
@ -47,6 +57,7 @@ public:
|
|||
std::array<nano::block_hash, 2> dependent_blocks (nano::transaction const &, nano::block const &) const;
|
||||
nano::account const & epoch_signer (nano::link const &) const;
|
||||
nano::link const & epoch_link (nano::epoch) const;
|
||||
std::multimap<uint64_t, uncemented_info, std::greater<>> unconfirmed_frontiers () const;
|
||||
static nano::uint128_t const unit;
|
||||
nano::network_params network_params;
|
||||
nano::block_store & store;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue