Cleanup
This commit is contained in:
parent
db23b9ace4
commit
e519bbb740
17 changed files with 56 additions and 34 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
#include <nano/node/confirming_set.hpp>
|
#include <nano/node/confirming_set.hpp>
|
||||||
#include <nano/node/election.hpp>
|
#include <nano/node/election.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/manual.hpp>
|
#include <nano/node/scheduler/manual.hpp>
|
||||||
#include <nano/node/scheduler/priority.hpp>
|
#include <nano/node/scheduler/priority.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <nano/lib/blocks.hpp>
|
#include <nano/lib/blocks.hpp>
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
#include <nano/node/election.hpp>
|
#include <nano/node/election.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/priority.hpp>
|
#include <nano/node/scheduler/priority.hpp>
|
||||||
#include <nano/node/vote_router.hpp>
|
#include <nano/node/vote_router.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
#include <nano/node/election.hpp>
|
#include <nano/node/election.hpp>
|
||||||
#include <nano/node/make_store.hpp>
|
#include <nano/node/make_store.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
#include <nano/secure/ledger_set_any.hpp>
|
#include <nano/secure/ledger_set_any.hpp>
|
||||||
#include <nano/secure/ledger_set_confirmed.hpp>
|
#include <nano/secure/ledger_set_confirmed.hpp>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <nano/node/inactive_node.hpp>
|
#include <nano/node/inactive_node.hpp>
|
||||||
#include <nano/node/local_vote_history.hpp>
|
#include <nano/node/local_vote_history.hpp>
|
||||||
#include <nano/node/make_store.hpp>
|
#include <nano/node/make_store.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/portmapping.hpp>
|
#include <nano/node/portmapping.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/manual.hpp>
|
#include <nano/node/scheduler/manual.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nano/lib/jsonconfig.hpp>
|
#include <nano/lib/jsonconfig.hpp>
|
||||||
#include <nano/lib/work_version.hpp>
|
#include <nano/lib/work_version.hpp>
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/telemetry.hpp>
|
#include <nano/node/telemetry.hpp>
|
||||||
#include <nano/node/transport/fake.hpp>
|
#include <nano/node/transport/fake.hpp>
|
||||||
#include <nano/node/vote_router.hpp>
|
#include <nano/node/vote_router.hpp>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include <nano/node/ipc/ipc_server.hpp>
|
#include <nano/node/ipc/ipc_server.hpp>
|
||||||
#include <nano/node/json_handler.hpp>
|
#include <nano/node/json_handler.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/transport/inproc.hpp>
|
#include <nano/node/transport/inproc.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
#include <nano/secure/ledger_set_any.hpp>
|
#include <nano/secure/ledger_set_any.hpp>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <nano/node/confirming_set.hpp>
|
#include <nano/node/confirming_set.hpp>
|
||||||
#include <nano/node/election.hpp>
|
#include <nano/node/election.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/repcrawler.hpp>
|
#include <nano/node/repcrawler.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/priority.hpp>
|
#include <nano/node/scheduler/priority.hpp>
|
||||||
|
|
@ -405,6 +406,7 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr<
|
||||||
{
|
{
|
||||||
result.inserted = true;
|
result.inserted = true;
|
||||||
auto observe_rep_cb = [&node = node] (auto const & rep_a) {
|
auto observe_rep_cb = [&node = node] (auto const & rep_a) {
|
||||||
|
// TODO: Is this neccessary? Move this outside of the election class
|
||||||
// Representative is defined as online if replying to live votes or rep_crawler queries
|
// Representative is defined as online if replying to live votes or rep_crawler queries
|
||||||
node.online_reps.observe (rep_a);
|
node.online_reps.observe (rep_a);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <nano/node/local_vote_history.hpp>
|
#include <nano/node/local_vote_history.hpp>
|
||||||
#include <nano/node/network.hpp>
|
#include <nano/node/network.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/vote_generator.hpp>
|
#include <nano/node/vote_generator.hpp>
|
||||||
#include <nano/node/vote_router.hpp>
|
#include <nano/node/vote_router.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include <nano/node/json_handler.hpp>
|
#include <nano/node/json_handler.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
#include <nano/node/node_rpc_config.hpp>
|
#include <nano/node/node_rpc_config.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/telemetry.hpp>
|
#include <nano/node/telemetry.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
#include <nano/secure/ledger_set_any.hpp>
|
#include <nano/secure/ledger_set_any.hpp>
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <nano/node/message_processor.hpp>
|
#include <nano/node/message_processor.hpp>
|
||||||
#include <nano/node/monitor.hpp>
|
#include <nano/node/monitor.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/peer_history.hpp>
|
#include <nano/node/peer_history.hpp>
|
||||||
#include <nano/node/portmapping.hpp>
|
#include <nano/node/portmapping.hpp>
|
||||||
#include <nano/node/request_aggregator.hpp>
|
#include <nano/node/request_aggregator.hpp>
|
||||||
|
|
@ -138,7 +139,8 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
|
||||||
rep_crawler (config.rep_crawler, *this),
|
rep_crawler (config.rep_crawler, *this),
|
||||||
rep_tiers{ ledger, network_params, online_reps, stats, logger },
|
rep_tiers{ ledger, network_params, online_reps, stats, logger },
|
||||||
warmed_up (0),
|
warmed_up (0),
|
||||||
online_reps (ledger, config),
|
online_reps_impl{ std::make_unique<nano::online_reps> (config, ledger) },
|
||||||
|
online_reps{ *online_reps_impl },
|
||||||
history_impl{ std::make_unique<nano::local_vote_history> (config.network_params.voting) },
|
history_impl{ std::make_unique<nano::local_vote_history> (config.network_params.voting) },
|
||||||
history{ *history_impl },
|
history{ *history_impl },
|
||||||
vote_uniquer{},
|
vote_uniquer{},
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <nano/node/node_observers.hpp>
|
#include <nano/node/node_observers.hpp>
|
||||||
#include <nano/node/nodeconfig.hpp>
|
#include <nano/node/nodeconfig.hpp>
|
||||||
#include <nano/node/online_reps.hpp>
|
#include <nano/node/online_reps.hpp>
|
||||||
|
#include <nano/node/portmapping.hpp>
|
||||||
#include <nano/node/process_live_dispatcher.hpp>
|
#include <nano/node/process_live_dispatcher.hpp>
|
||||||
#include <nano/node/rep_tiers.hpp>
|
#include <nano/node/rep_tiers.hpp>
|
||||||
#include <nano/node/repcrawler.hpp>
|
#include <nano/node/repcrawler.hpp>
|
||||||
|
|
@ -39,6 +40,7 @@ class message_processor;
|
||||||
class monitor;
|
class monitor;
|
||||||
class node;
|
class node;
|
||||||
class telemetry;
|
class telemetry;
|
||||||
|
class online_reps;
|
||||||
class vote_processor;
|
class vote_processor;
|
||||||
class vote_cache_processor;
|
class vote_cache_processor;
|
||||||
class vote_router;
|
class vote_router;
|
||||||
|
|
@ -176,7 +178,8 @@ public:
|
||||||
nano::bucketing & bucketing;
|
nano::bucketing & bucketing;
|
||||||
std::unique_ptr<nano::active_elections> active_impl;
|
std::unique_ptr<nano::active_elections> active_impl;
|
||||||
nano::active_elections & active;
|
nano::active_elections & active;
|
||||||
nano::online_reps online_reps;
|
std::unique_ptr<nano::online_reps> online_reps_impl;
|
||||||
|
nano::online_reps & online_reps;
|
||||||
nano::rep_crawler rep_crawler;
|
nano::rep_crawler rep_crawler;
|
||||||
nano::rep_tiers rep_tiers;
|
nano::rep_tiers rep_tiers;
|
||||||
unsigned warmed_up;
|
unsigned warmed_up;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include <nano/store/component.hpp>
|
#include <nano/store/component.hpp>
|
||||||
#include <nano/store/online_weight.hpp>
|
#include <nano/store/online_weight.hpp>
|
||||||
|
|
||||||
nano::online_reps::online_reps (nano::ledger & ledger_a, nano::node_config const & config_a) :
|
nano::online_reps::online_reps (nano::node_config const & config_a, nano::ledger & ledger_a) :
|
||||||
ledger{ ledger_a },
|
config{ config_a },
|
||||||
config{ config_a }
|
ledger{ ledger_a }
|
||||||
{
|
{
|
||||||
if (!ledger.store.init_error ())
|
if (!ledger.store.init_error ())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nano/lib/numbers.hpp>
|
#include <nano/lib/numbers.hpp>
|
||||||
#include <nano/lib/numbers_templ.hpp>
|
#include <nano/lib/numbers_templ.hpp>
|
||||||
#include <nano/lib/utility.hpp>
|
#include <nano/lib/utility.hpp>
|
||||||
|
#include <nano/node/fwd.hpp>
|
||||||
#include <nano/secure/common.hpp>
|
#include <nano/secure/common.hpp>
|
||||||
|
|
||||||
#include <boost/multi_index/hashed_index.hpp>
|
#include <boost/multi_index/hashed_index.hpp>
|
||||||
|
|
@ -13,24 +14,21 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace mi = boost::multi_index;
|
||||||
|
|
||||||
namespace nano
|
namespace nano
|
||||||
{
|
{
|
||||||
class ledger;
|
|
||||||
class node_config;
|
|
||||||
namespace store
|
|
||||||
{
|
|
||||||
class transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Track online representatives and trend online weight */
|
/** Track online representatives and trend online weight */
|
||||||
class online_reps final
|
class online_reps final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
online_reps (nano::ledger & ledger_a, nano::node_config const & config_a);
|
online_reps (nano::node_config const &, nano::ledger &);
|
||||||
|
|
||||||
/** Add voting account \p rep_account to the set of online representatives */
|
/** Add voting account \p rep_account to the set of online representatives */
|
||||||
void observe (nano::account const & rep_account);
|
void observe (nano::account const & rep_account);
|
||||||
/** Called periodically to sample online weight */
|
/** Called periodically to sample online weight */
|
||||||
void sample ();
|
void sample ();
|
||||||
|
|
||||||
/** Returns the trended online stake */
|
/** Returns the trended online stake */
|
||||||
nano::uint128_t trended () const;
|
nano::uint128_t trended () const;
|
||||||
/** Returns the current online stake */
|
/** Returns the current online stake */
|
||||||
|
|
@ -45,34 +43,39 @@ public:
|
||||||
public:
|
public:
|
||||||
static unsigned constexpr online_weight_quorum = 67;
|
static unsigned constexpr online_weight_quorum = 67;
|
||||||
|
|
||||||
|
private: // Dependencies
|
||||||
|
nano::node_config const & config;
|
||||||
|
nano::ledger & ledger;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class rep_info
|
nano::uint128_t calculate_trend (nano::store::transaction &) const;
|
||||||
|
nano::uint128_t calculate_online () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct rep_info
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
std::chrono::steady_clock::time_point time;
|
std::chrono::steady_clock::time_point time;
|
||||||
nano::account account;
|
nano::account account;
|
||||||
};
|
};
|
||||||
class tag_time
|
|
||||||
{
|
// clang-format off
|
||||||
};
|
class tag_time {};
|
||||||
class tag_account
|
class tag_account {};
|
||||||
{
|
|
||||||
};
|
using ordered_reps = boost::multi_index_container<rep_info,
|
||||||
nano::uint128_t calculate_trend (store::transaction &) const;
|
mi::indexed_by<
|
||||||
nano::uint128_t calculate_online () const;
|
mi::ordered_non_unique<mi::tag<tag_time>,
|
||||||
mutable nano::mutex mutex;
|
mi::member<rep_info, std::chrono::steady_clock::time_point, &rep_info::time>>,
|
||||||
nano::ledger & ledger;
|
mi::hashed_unique<mi::tag<tag_account>,
|
||||||
nano::node_config const & config;
|
mi::member<rep_info, nano::account, &rep_info::account>>
|
||||||
boost::multi_index_container<rep_info,
|
>>;
|
||||||
boost::multi_index::indexed_by<
|
// clang-format off
|
||||||
boost::multi_index::ordered_non_unique<boost::multi_index::tag<tag_time>,
|
ordered_reps reps;
|
||||||
boost::multi_index::member<rep_info, std::chrono::steady_clock::time_point, &rep_info::time>>,
|
|
||||||
boost::multi_index::hashed_unique<boost::multi_index::tag<tag_account>,
|
|
||||||
boost::multi_index::member<rep_info, nano::account, &rep_info::account>>>>
|
|
||||||
reps;
|
|
||||||
nano::uint128_t trended_m;
|
nano::uint128_t trended_m;
|
||||||
nano::uint128_t online_m;
|
nano::uint128_t online_m;
|
||||||
nano::uint128_t minimum;
|
|
||||||
|
mutable nano::mutex mutex;
|
||||||
|
|
||||||
friend class election_quorum_minimum_update_weight_before_quorum_checks_Test;
|
friend class election_quorum_minimum_update_weight_before_quorum_checks_Test;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/repcrawler.hpp>
|
#include <nano/node/repcrawler.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
#include <nano/secure/vote.hpp>
|
#include <nano/secure/vote.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nano/node/active_elections.hpp>
|
#include <nano/node/active_elections.hpp>
|
||||||
#include <nano/node/election_behavior.hpp>
|
#include <nano/node/election_behavior.hpp>
|
||||||
#include <nano/node/node.hpp>
|
#include <nano/node/node.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/scheduler/hinted.hpp>
|
#include <nano/node/scheduler/hinted.hpp>
|
||||||
#include <nano/secure/ledger.hpp>
|
#include <nano/secure/ledger.hpp>
|
||||||
#include <nano/secure/ledger_set_any.hpp>
|
#include <nano/secure/ledger_set_any.hpp>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <nano/node/ipc/ipc_server.hpp>
|
#include <nano/node/ipc/ipc_server.hpp>
|
||||||
#include <nano/node/json_handler.hpp>
|
#include <nano/node/json_handler.hpp>
|
||||||
#include <nano/node/node_rpc_config.hpp>
|
#include <nano/node/node_rpc_config.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/manual.hpp>
|
#include <nano/node/scheduler/manual.hpp>
|
||||||
#include <nano/node/scheduler/priority.hpp>
|
#include <nano/node/scheduler/priority.hpp>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <nano/node/confirming_set.hpp>
|
#include <nano/node/confirming_set.hpp>
|
||||||
#include <nano/node/election.hpp>
|
#include <nano/node/election.hpp>
|
||||||
#include <nano/node/make_store.hpp>
|
#include <nano/node/make_store.hpp>
|
||||||
|
#include <nano/node/online_reps.hpp>
|
||||||
#include <nano/node/scheduler/component.hpp>
|
#include <nano/node/scheduler/component.hpp>
|
||||||
#include <nano/node/scheduler/manual.hpp>
|
#include <nano/node/scheduler/manual.hpp>
|
||||||
#include <nano/node/scheduler/priority.hpp>
|
#include <nano/node/scheduler/priority.hpp>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue