diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 142da6b554..555cc9ab6e 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -50,7 +50,7 @@ TEST (active_transactions, confirm_active) nano::lock_guard guard (node2.rep_crawler.probable_reps_mutex); node2.rep_crawler.probable_reps.emplace (nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, *peers.begin ()); } - ASSERT_TIMELY (5s, election->votes ().size () != 1); // Votes were inserted (except for not_an_account) + ASSERT_TIMELY (5s, election->votes ().size () != 1); // Votes were inserted (except for the null account) auto confirm_req_count (election->confirmation_request_count.load ()); // At least one confirmation request ASSERT_GT (confirm_req_count, 0u); @@ -62,7 +62,7 @@ TEST (active_transactions, confirm_active) ASSERT_TIMELY (10s, node2.ledger.cache.cemented_count == 2 && node2.active.empty ()); // At least one more confirmation request ASSERT_GT (election->confirmation_request_count, confirm_req_count); - // Blocks were cleared (except for not_an_account) + // Blocks were cleared (except for the null account) ASSERT_EQ (1, election->blocks ().size ()); } } diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index 0e4411b665..f4529dc7db 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -523,7 +523,7 @@ TEST (block_store, frontier_retrieval) nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants); ASSERT_TRUE (!store->init_error ()); - nano::account account1 (0); + nano::account account1{}; nano::account_info info1 (0, 0, 0, 0, 0, 0, nano::epoch::epoch_0); auto transaction (store->tx_begin_write ()); store->confirmation_height.put (transaction, account1, { 0, nano::block_hash (0) }); @@ -538,7 +538,7 @@ TEST (block_store, one_account) nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants); ASSERT_TRUE (!store->init_error ()); - nano::account account (0); + nano::account account{}; nano::block_hash hash (0); auto transaction (store->tx_begin_write ()); store->confirmation_height.put (transaction, account, { 20, nano::block_hash (15) }); @@ -783,7 +783,7 @@ TEST (block_store, large_iteration) store->account.put (transaction, account, nano::account_info ()); } std::unordered_set accounts2; - nano::account previous (0); + nano::account previous{}; auto transaction (store->tx_begin_read ()); for (auto i (store->account.begin (transaction, 0)), n (store->account.end ()); i != n; ++i) { @@ -1874,9 +1874,9 @@ TEST (block_store, confirmation_height) nano::logger_mt logger; auto store = nano::make_store (logger, path, nano::dev::constants); - nano::account account1 (0); - nano::account account2 (1); - nano::account account3 (2); + nano::account account1{}; + nano::account account2{ 1 }; + nano::account account3{ 2 }; nano::block_hash cemented_frontier1 (3); nano::block_hash cemented_frontier2 (4); nano::block_hash cemented_frontier3 (5); diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 6cb0bdd8a6..357249df54 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -1525,13 +1525,13 @@ TEST (ledger, block_destination_source) ASSERT_TRUE (ledger.block_source (transaction, block1).is_zero ()); ASSERT_EQ (nano::dev::genesis->account (), ledger.block_destination (transaction, block2)); ASSERT_TRUE (ledger.block_source (transaction, block2).is_zero ()); - ASSERT_TRUE (ledger.block_destination (transaction, block3).is_zero ()); + ASSERT_TRUE (ledger.block_destination (transaction, block3) == nullptr); ASSERT_EQ (block2.hash (), ledger.block_source (transaction, block3)); ASSERT_EQ (dest.pub, ledger.block_destination (transaction, block4)); ASSERT_TRUE (ledger.block_source (transaction, block4).is_zero ()); ASSERT_EQ (nano::dev::genesis->account (), ledger.block_destination (transaction, block5)); ASSERT_TRUE (ledger.block_source (transaction, block5).is_zero ()); - ASSERT_TRUE (ledger.block_destination (transaction, block6).is_zero ()); + ASSERT_TRUE (ledger.block_destination (transaction, block6) == nullptr); ASSERT_EQ (block5.hash (), ledger.block_source (transaction, block6)); } @@ -2411,7 +2411,7 @@ TEST (ledger, epoch_blocks_fork) store->initialize (transaction, ledger.cache); nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; nano::keypair destination; - nano::send_block send1 (nano::dev::genesis->hash (), nano::account (0), nano::dev::constants.genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::account{}, nano::dev::constants.genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, epoch1).code); diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 5d6040f300..3fb8cad945 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -797,7 +797,7 @@ TEST (tcp_listener, tcp_node_id_handshake) ASSERT_TIMELY (5s, write_done); - boost::optional> response_zero (std::make_pair (nano::account (0), nano::signature (0))); + boost::optional> response_zero (std::make_pair (nano::account{}, nano::signature (0))); nano::node_id_handshake node_id_handshake_response{ nano::dev::network_params.network, boost::none, response_zero }; auto output (node_id_handshake_response.to_bytes ()); std::atomic done (false); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index bdf36925ad..5775f1abaf 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -20,6 +20,17 @@ namespace void add_required_children_node_config_tree (nano::jsonconfig & tree); } +TEST (node, null_account) +{ + const auto & null_account = nano::account::null (); + ASSERT_TRUE (null_account == nullptr); + ASSERT_FALSE (null_account != nullptr); + + nano::account default_account{}; + ASSERT_FALSE (default_account == nullptr); + ASSERT_TRUE (default_account != nullptr); +} + TEST (node, stop) { nano::system system (1); diff --git a/nano/core_test/system.cpp b/nano/core_test/system.cpp index fd129c8904..4854fbd73f 100644 --- a/nano/core_test/system.cpp +++ b/nano/core_test/system.cpp @@ -106,7 +106,7 @@ TEST (system, DISABLED_generate_send_new) // This indirectly waits for online weight to stabilize, required to prevent intermittent failures ASSERT_TIMELY (5s, node1.wallets.reps ().voting > 0); system.generate_send_new (node1, accounts); - nano::account new_account (0); + nano::account new_account{}; { auto transaction (node1.wallets.tx_begin_read ()); auto iterator2 (system.wallet (0)->store.begin (transaction)); diff --git a/nano/core_test/wallet.cpp b/nano/core_test/wallet.cpp index 295e02624b..010b135cbb 100644 --- a/nano/core_test/wallet.cpp +++ b/nano/core_test/wallet.cpp @@ -335,7 +335,7 @@ TEST (wallet, rekey) TEST (account, encode_zero) { - nano::account number0 (0); + nano::account number0{}; std::string str0; number0.encode_account (str0); @@ -367,7 +367,7 @@ TEST (account, encode_all) TEST (account, encode_fail) { - nano::account number0 (0); + nano::account number0{}; std::string str0; number0.encode_account (str0); str0[16] ^= 1; diff --git a/nano/lib/blocks.cpp b/nano/lib/blocks.cpp index 8b6d319c6b..28996148a0 100644 --- a/nano/lib/blocks.cpp +++ b/nano/lib/blocks.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -151,8 +152,8 @@ bool nano::block::has_sideband () const nano::account const & nano::block::representative () const { - static nano::account rep{ 0 }; - return rep; + static nano::account representative{}; + return representative; } nano::block_hash const & nano::block::source () const @@ -163,7 +164,7 @@ nano::block_hash const & nano::block::source () const nano::account const & nano::block::destination () const { - static nano::account destination{ 0 }; + static nano::account destination{}; return destination; } @@ -175,7 +176,7 @@ nano::link const & nano::block::link () const nano::account const & nano::block::account () const { - static nano::account account{ 0 }; + static nano::account account{}; return account; } @@ -363,6 +364,8 @@ nano::send_block::send_block (nano::block_hash const & previous_a, nano::account signature (nano::sign_message (prv_a, pub_a, hash ())), work (work_a) { + debug_assert (destination_a != nullptr); + debug_assert (pub_a != nullptr); } nano::send_block::send_block (bool & error_a, nano::stream & stream_a) : @@ -524,13 +527,18 @@ nano::open_block::open_block (nano::block_hash const & source_a, nano::account c signature (nano::sign_message (prv_a, pub_a, hash ())), work (work_a) { - debug_assert (!representative_a.is_zero ()); + debug_assert (representative_a != nullptr); + debug_assert (account_a != nullptr); + debug_assert (pub_a != nullptr); } nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, std::nullptr_t) : hashables (source_a, representative_a, account_a), work (0) { + debug_assert (representative_a != nullptr); + debug_assert (account_a != nullptr); + signature.clear (); } @@ -787,6 +795,8 @@ nano::change_block::change_block (nano::block_hash const & previous_a, nano::acc signature (nano::sign_message (prv_a, pub_a, hash ())), work (work_a) { + debug_assert (representative_a != nullptr); + debug_assert (pub_a != nullptr); } nano::change_block::change_block (bool & error_a, nano::stream & stream_a) : @@ -1060,6 +1070,10 @@ nano::state_block::state_block (nano::account const & account_a, nano::block_has signature (nano::sign_message (prv_a, pub_a, hash ())), work (work_a) { + debug_assert (account_a != nullptr); + debug_assert (representative_a != nullptr); + debug_assert (link_a.as_account () != nullptr); + debug_assert (pub_a != nullptr); } nano::state_block::state_block (bool & error_a, nano::stream & stream_a) : @@ -1505,6 +1519,7 @@ nano::receive_block::receive_block (nano::block_hash const & previous_a, nano::b signature (nano::sign_message (prv_a, pub_a, hash ())), work (work_a) { + debug_assert (pub_a != nullptr); } nano::receive_block::receive_block (bool & error_a, nano::stream & stream_a) : diff --git a/nano/lib/blocks.hpp b/nano/lib/blocks.hpp index b3412f479d..5a5b875e84 100644 --- a/nano/lib/blocks.hpp +++ b/nano/lib/blocks.hpp @@ -64,7 +64,7 @@ class block_sideband final bool deserialize (nano::stream &, nano::block_type); static size_t size (nano::block_type); nano::block_hash successor{ 0 }; - nano::account account{ 0 }; + nano::account account{}; nano::amount balance{ 0 }; uint64_t height{ 0 }; uint64_t timestamp{ 0 }; diff --git a/nano/lib/numbers.cpp b/nano/lib/numbers.cpp index 2798cc96be..e6206aa512 100644 --- a/nano/lib/numbers.cpp +++ b/nano/lib/numbers.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,16 @@ std::string nano::public_key::to_account () const return result; } +nano::public_key::public_key () : + uint256_union{ 0 } +{ +} + +const nano::public_key & nano::public_key::null () +{ + return nano::hardened_constants::get ().not_an_account; +} + std::string nano::public_key::to_node_id () const { return to_account ().replace (0, 4, "node"); @@ -781,6 +792,11 @@ std::string nano::uint128_union::to_string_dec () const return result; } +nano::hash_or_account::hash_or_account () : + account{} +{ +} + nano::hash_or_account::hash_or_account (uint64_t value_a) : raw (value_a) { @@ -939,6 +955,16 @@ nano::public_key::operator nano::hash_or_account const & () const return reinterpret_cast (*this); } +bool nano::public_key::operator== (std::nullptr_t) const +{ + return bytes == null ().bytes; +} + +bool nano::public_key::operator!= (std::nullptr_t) const +{ + return !(*this == nullptr); +} + nano::block_hash::operator nano::link const & () const { return reinterpret_cast (*this); diff --git a/nano/lib/numbers.hpp b/nano/lib/numbers.hpp index 3e2e64eb0c..fc9542110a 100644 --- a/nano/lib/numbers.hpp +++ b/nano/lib/numbers.hpp @@ -115,6 +115,10 @@ class public_key final : public uint256_union public: using uint256_union::uint256_union; + public_key (); + + static const public_key & null (); + std::string to_node_id () const; bool decode_node_id (std::string const & source_a); void encode_account (std::string &) const; @@ -124,6 +128,10 @@ class public_key final : public uint256_union operator nano::link const & () const; operator nano::root const & () const; operator nano::hash_or_account const & () const; + bool operator== (std::nullptr_t) const; + bool operator!= (std::nullptr_t) const; + using uint256_union::operator==; + using uint256_union::operator!=; }; class wallet_id : public uint256_union @@ -137,7 +145,7 @@ using account = public_key; class hash_or_account { public: - hash_or_account () = default; + hash_or_account (); hash_or_account (uint64_t value_a); bool is_zero () const; diff --git a/nano/lib/walletconfig.hpp b/nano/lib/walletconfig.hpp index 68f9fcc1df..6a04206a90 100644 --- a/nano/lib/walletconfig.hpp +++ b/nano/lib/walletconfig.hpp @@ -19,6 +19,6 @@ class wallet_config final nano::error serialize_toml (nano::tomlconfig & toml_a) const; nano::error deserialize_toml (nano::tomlconfig & toml_a); nano::wallet_id wallet; - nano::account account{ 0 }; + nano::account account{}; }; } diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 143667299f..593a68695c 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -1459,7 +1459,7 @@ int main (int argc, char * const * argv) } } uint64_t previous_timestamp (0); - nano::account calculated_representative (0); + nano::account calculated_representative{}; while (!hash.is_zero () && block != nullptr) { ++block_count; @@ -1704,7 +1704,7 @@ int main (int argc, char * const * argv) else { // Check if pending destination is correct - nano::account destination (0); + nano::account destination{}; bool previous_pruned = node->ledger.pruning && node->store.pruned.exists (transaction, block->previous ()); if (previous_pruned) { diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index a2e83e36f6..b296c024b0 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -180,11 +180,11 @@ void nano::active_transactions::block_cemented_callback (std::shared_ptrhash (), account, amount, is_state_send, is_state_epoch, pending_account); node.observers.blocks.notify (nano::election_status{ block_a, 0, 0, std::chrono::duration_cast (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values::zero (), 0, 1, 0, nano::election_status_type::inactive_confirmation_height }, {}, account, amount, is_state_send, is_state_epoch); } @@ -206,11 +206,11 @@ void nano::active_transactions::block_cemented_callback (std::shared_ptrlink ().is_zero () ? block_a->destination () : block_a->link ().as_account ()); node.receive_confirmed (transaction, hash, destination); - nano::account account (0); + nano::account account{}; nano::uint128_t amount (0); bool is_state_send (false); bool is_state_epoch (false); - nano::account pending_account (0); + nano::account pending_account{}; node.process_confirmed_data (transaction, block_a, hash, account, amount, is_state_send, is_state_epoch, pending_account); election_lk.lock (); election->status.type = *election_status_type; diff --git a/nano/node/active_transactions.hpp b/nano/node/active_transactions.hpp index e4432b3afa..4fe84eb34d 100644 --- a/nano/node/active_transactions.hpp +++ b/nano/node/active_transactions.hpp @@ -279,7 +279,7 @@ class active_transactions final void confirm_expired_frontiers_pessimistically (nano::transaction const &, uint64_t, uint64_t &); void frontiers_confirmation (nano::unique_lock &); bool insert_election_from_frontiers_confirmation (std::shared_ptr const &, nano::account const &, nano::uint128_t, nano::election_behavior); - nano::account next_frontier_account{ 0 }; + nano::account next_frontier_account{}; std::chrono::steady_clock::time_point next_frontier_check{ std::chrono::steady_clock::now () }; constexpr static size_t max_active_elections_frontier_insertion{ 1000 }; prioritize_num_uncemented priority_wallet_cementable_frontiers; diff --git a/nano/node/bootstrap/bootstrap.hpp b/nano/node/bootstrap/bootstrap.hpp index 4d70bab086..b26d55f98e 100644 --- a/nano/node/bootstrap/bootstrap.hpp +++ b/nano/node/bootstrap/bootstrap.hpp @@ -82,7 +82,7 @@ class bootstrap_initiator final explicit bootstrap_initiator (nano::node &); ~bootstrap_initiator (); void bootstrap (nano::endpoint const &, bool add_to_peers = true, std::string id_a = ""); - void bootstrap (bool force = false, std::string id_a = "", uint32_t const frontiers_age_a = std::numeric_limits::max (), nano::account const & start_account_a = nano::account (0)); + void bootstrap (bool force = false, std::string id_a = "", uint32_t const frontiers_age_a = std::numeric_limits::max (), nano::account const & start_account_a = nano::account{}); bool bootstrap_lazy (nano::hash_or_account const &, bool force = false, bool confirmed = true, std::string id_a = ""); void bootstrap_wallet (std::deque &); void run_bootstrap (); diff --git a/nano/node/bootstrap/bootstrap_attempt.cpp b/nano/node/bootstrap/bootstrap_attempt.cpp index eac672c1d3..801c7f0a8e 100644 --- a/nano/node/bootstrap/bootstrap_attempt.cpp +++ b/nano/node/bootstrap/bootstrap_attempt.cpp @@ -23,9 +23,9 @@ nano::bootstrap_attempt::bootstrap_attempt (std::shared_ptr const & { if (id.empty ()) { - nano::random_constants constants; - id = constants.random_128.to_string (); + id = nano::hardened_constants::get ().random_128.to_string (); } + node->logger.always_log (boost::str (boost::format ("Starting %1% bootstrap attempt with ID %2%") % mode_text () % id)); node->bootstrap_initiator.notify_listeners (true); if (node->websocket_server) diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.cpp b/nano/node/bootstrap/bootstrap_bulk_pull.cpp index 9f6178d3f7..0f87250f97 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.cpp @@ -21,7 +21,7 @@ nano::pull_info::pull_info (nano::hash_or_account const & account_or_head_a, nan nano::bulk_pull_client::bulk_pull_client (std::shared_ptr const & connection_a, std::shared_ptr const & attempt_a, nano::pull_info const & pull_a) : connection (connection_a), attempt (attempt_a), - known_account (0), + known_account{}, pull (pull_a), pull_blocks (0), unexpected_count (0) diff --git a/nano/node/bootstrap/bootstrap_frontier.cpp b/nano/node/bootstrap/bootstrap_frontier.cpp index c15d791348..277ef0da5a 100644 --- a/nano/node/bootstrap/bootstrap_frontier.cpp +++ b/nano/node/bootstrap/bootstrap_frontier.cpp @@ -224,11 +224,11 @@ void nano::frontier_req_client::next () nano::account const & account (i->first); accounts.emplace_back (account, info.head); } - /* If loop breaks before max_size, then accounts_end () is reached - Add empty record */ + + /* If loop breaks before max_size, then accounts_end () is reached. Add empty record */ if (accounts.size () != max_size) { - accounts.emplace_back (nano::account (0), nano::block_hash (0)); + accounts.emplace_back (nano::account{}, nano::block_hash (0)); } } // Retrieving accounts from deque @@ -360,11 +360,11 @@ void nano::frontier_req_server::next () } } } - /* If loop breaks before max_size, then accounts_end () is reached - Add empty record to finish frontier_req_server */ + + /* If loop breaks before max_size, then accounts_end () is reached. Add empty record to finish frontier_req_server */ if (accounts.size () != max_size) { - accounts.emplace_back (nano::account (0), nano::block_hash (0)); + accounts.emplace_back (nano::account{}, nano::block_hash (0)); } } // Retrieving accounts from deque diff --git a/nano/node/bootstrap/bootstrap_legacy.hpp b/nano/node/bootstrap/bootstrap_legacy.hpp index 0abe0f901c..7387556e43 100644 --- a/nano/node/bootstrap/bootstrap_legacy.hpp +++ b/nano/node/bootstrap/bootstrap_legacy.hpp @@ -33,7 +33,7 @@ class bootstrap_attempt_legacy : public bootstrap_attempt std::weak_ptr push; std::deque frontier_pulls; std::vector> bulk_push_targets; - nano::account start_account{ 0 }; + nano::account start_account{}; std::atomic account_count{ 0 }; uint32_t frontiers_age; }; diff --git a/nano/node/bootstrap/bootstrap_server.hpp b/nano/node/bootstrap/bootstrap_server.hpp index 1b6b4a3e2f..58ee8958a4 100644 --- a/nano/node/bootstrap/bootstrap_server.hpp +++ b/nano/node/bootstrap/bootstrap_server.hpp @@ -66,7 +66,7 @@ class bootstrap_server final : public std::enable_shared_from_this stopped{ false }; // Remote enpoint used to remove response channel even after socket closing nano::tcp_endpoint remote_endpoint{ boost::asio::ip::address_v6::any (), 0 }; - nano::account remote_node_id{ 0 }; + nano::account remote_node_id{}; std::chrono::steady_clock::time_point last_telemetry_req{ std::chrono::steady_clock::time_point () }; }; } diff --git a/nano/node/common.cpp b/nano/node/common.cpp index 11358d1bfd..4dda2bed4d 100644 --- a/nano/node/common.cpp +++ b/nano/node/common.cpp @@ -23,14 +23,13 @@ std::chrono::seconds constexpr nano::telemetry_cache_cutoffs::live; uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint16_t port) { - static nano::random_constants constants; debug_assert (ip_a.is_v6 ()); uint64_t result; nano::uint128_union address; address.bytes = ip_a.to_v6 ().to_bytes (); blake2b_state state; blake2b_init (&state, sizeof (result)); - blake2b_update (&state, constants.random_128.bytes.data (), constants.random_128.bytes.size ()); + blake2b_update (&state, nano::hardened_constants::get ().random_128.bytes.data (), nano::hardened_constants::get ().random_128.bytes.size ()); if (port != 0) { blake2b_update (&state, &port, sizeof (port)); diff --git a/nano/node/common.hpp b/nano/node/common.hpp index d3b5627e92..1b2739cd59 100644 --- a/nano/node/common.hpp +++ b/nano/node/common.hpp @@ -354,7 +354,7 @@ class telemetry_data { public: nano::signature signature{ 0 }; - nano::account node_id{ 0 }; + nano::account node_id{}; uint64_t block_count{ 0 }; uint64_t cemented_count{ 0 }; uint64_t unchecked_count{ 0 }; diff --git a/nano/node/election.cpp b/nano/node/election.cpp index e730f15796..22d3421baf 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -28,7 +28,7 @@ nano::election::election (nano::node & node_a, std::shared_ptr cons root (block_a->root ()), qualified_root (block_a->qualified_root ()) { - last_votes.emplace (node.network_params.random.not_an_account, nano::vote_info{ std::chrono::steady_clock::now (), 0, block_a->hash () }); + last_votes.emplace (nano::account::null (), nano::vote_info{ std::chrono::steady_clock::now (), 0, block_a->hash () }); last_blocks.emplace (block_a->hash (), block_a); if (node.config.enable_voting && node.wallets.reps ().voting > 0) { @@ -319,7 +319,7 @@ void nano::election::log_votes (nano::tally_t const & tally_a, std::string const } for (auto i (last_votes.begin ()), n (last_votes.end ()); i != n; ++i) { - if (i->first != node.network_params.random.not_an_account) + if (i->first != nullptr) { tally << boost::str (boost::format ("%1%%2% %3% %4%") % line_end % i->first.to_account () % std::to_string (i->second.timestamp) % i->second.hash.to_string ()); } @@ -459,7 +459,7 @@ size_t nano::election::insert_inactive_votes_cache (nano::inactive_cache_informa node.stats.add (nano::stat::type::election, nano::stat::detail::late_block_seconds, nano::stat::dir::in, delay.count (), true); } } - if (last_votes.size () > 1) // not_an_account + if (last_votes.size () > 1) // null account { // Even if no votes were in cache, they could be in the election confirm_if_quorum (lock); @@ -629,7 +629,7 @@ std::vector nano::election::votes_with_weight () co auto votes_l (votes ()); for (auto const & vote_l : votes_l) { - if (vote_l.first != node.network_params.random.not_an_account) + if (vote_l.first != nullptr) { auto amount (node.ledger.cache.rep_weights.representation_get (vote_l.first)); nano::vote_with_weight_info vote_info{ vote_l.first, vote_l.second.time, vote_l.second.timestamp, vote_l.second.hash, amount }; diff --git a/nano/node/ipc/action_handler.cpp b/nano/node/ipc/action_handler.cpp index 76086e737c..db191f77b2 100644 --- a/nano/node/ipc/action_handler.cpp +++ b/nano/node/ipc/action_handler.cpp @@ -11,11 +11,12 @@ namespace { nano::account parse_account (std::string const & account, bool & out_is_deprecated_format) { - nano::account result (0); + nano::account result{}; if (account.empty ()) { throw nano::error (nano::error_common::bad_account_number); } + if (result.decode_account (account)) { throw nano::error (nano::error_common::bad_account_number); diff --git a/nano/node/ipc/ipc_broker.cpp b/nano/node/ipc/ipc_broker.cpp index 77712bfc0a..9b3477c25d 100644 --- a/nano/node/ipc/ipc_broker.cpp +++ b/nano/node/ipc/ipc_broker.cpp @@ -144,7 +144,8 @@ void nano::ipc::broker::broadcast (std::shared_ptr if (itr->topic->options->all_local_accounts) { auto transaction_l (this->node.wallets.tx_begin_read ()); - nano::account source_l (0), destination_l (0); + nano::account source_l{}; + nano::account destination_l{}; auto decode_source_ok_l (!source_l.decode_account (state->account)); auto decode_destination_ok_l (!destination_l.decode_account (state->link_as_account)); (void)decode_source_ok_l; diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 2e2e03cdcf..4d6ac1c3ab 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -235,7 +235,7 @@ bool nano::json_handler::wallet_account_impl (nano::transaction const & transact nano::account nano::json_handler::account_impl (std::string account_text, std::error_code ec_a) { - nano::account result (0); + nano::account result{}; if (!ec) { if (account_text.empty ()) @@ -671,7 +671,7 @@ void nano::json_handler::account_info () response_l.put ("representative", info.representative.to_account ()); if (include_confirmed) { - nano::account confirmed_representative{ 0 }; + nano::account confirmed_representative{}; if (confirmed_frontier_block) { confirmed_representative = confirmed_frontier_block->representative (); @@ -1053,7 +1053,7 @@ void nano::json_handler::available_supply () auto genesis_balance (node.balance (node.network_params.ledger.genesis->account ())); // Cold storage genesis auto landing_balance (node.balance (nano::account ("059F68AAB29DE0D3A27443625C7EA9CDDB6517A8B76FE37727EF6A4D76832AD5"))); // Active unavailable account auto faucet_balance (node.balance (nano::account ("8E319CE6F3025E5B2DF66DA7AB1467FE48F1679C13DD43BFDB29FA2E9FC40D3B"))); // Faucet account - auto burned_balance ((node.balance_pending (nano::account (0), false)).second); // Burning 0 account + auto burned_balance ((node.balance_pending (nano::account{}, false)).second); // Burning 0 account auto available (nano::dev::constants.genesis_amount - genesis_balance - landing_balance - faucet_balance - burned_balance); response_l.put ("available", available.convert_to ()); response_errors (); @@ -1360,19 +1360,19 @@ void nano::json_handler::block_create () ec = nano::error_common::bad_wallet_number; } } - nano::account account (0); + nano::account account{}; boost::optional account_text (request.get_optional ("account")); if (!ec && account_text.is_initialized ()) { account = account_impl (account_text.get ()); } - nano::account representative (0); + nano::account representative{}; boost::optional representative_text (request.get_optional ("representative")); if (!ec && representative_text.is_initialized ()) { representative = account_impl (representative_text.get (), nano::error_rpc::bad_representative_number); } - nano::account destination (0); + nano::account destination{}; boost::optional destination_text (request.get_optional ("destination")); if (!ec && destination_text.is_initialized ()) { @@ -1739,7 +1739,7 @@ void nano::json_handler::bootstrap_any () const bool force = request.get ("force", false); if (!node.flags.disable_legacy_bootstrap) { - nano::account start_account (0); + nano::account start_account{}; boost::optional account_text (request.get_optional ("account")); if (account_text.is_initialized ()) { @@ -2095,7 +2095,7 @@ void nano::json_handler::delegators () auto threshold (threshold_optional_impl ()); auto start_account_text (request.get_optional ("start")); - nano::account start_account (0); + nano::account start_account{}; if (!ec && start_account_text.is_initialized ()) { start_account = account_impl (start_account_text.get ()); @@ -2622,7 +2622,7 @@ void nano::json_handler::ledger () auto threshold (threshold_optional_impl ()); if (!ec) { - nano::account start (0); + nano::account start{}; boost::optional account_text (request.get_optional ("account")); if (account_text.is_initialized ()) { diff --git a/nano/node/node.cpp b/nano/node/node.cpp index aeefd89ee9..0cbd75d94a 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1496,7 +1496,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e class account_upgrade_item final { public: - nano::account account{ 0 }; + nano::account account{}; uint64_t modified{ 0 }; }; class account_tag diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index 2d26bb83ba..aa68fa4aa2 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -248,7 +248,7 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) { preconfigured_representatives.clear (); toml.array_entries_required ("preconfigured_representatives", [this, &toml] (std::string entry) { - nano::account representative (0); + nano::account representative{}; if (representative.decode_account (entry)) { toml.get_error ().set ("Invalid representative account: " + entry); @@ -583,7 +583,7 @@ nano::error nano::node_config::deserialize_json (bool & upgraded_a, nano::jsonco auto preconfigured_representatives_l (json.get_required_child ("preconfigured_representatives")); preconfigured_representatives.clear (); preconfigured_representatives_l.array_entries ([this, &json] (std::string entry) { - nano::account representative (0); + nano::account representative{}; if (representative.decode_account (entry)) { json.get_error ().set ("Invalid representative account: " + entry); diff --git a/nano/node/repcrawler.hpp b/nano/node/repcrawler.hpp index cfe7fb9821..7586945a50 100644 --- a/nano/node/repcrawler.hpp +++ b/nano/node/repcrawler.hpp @@ -41,7 +41,7 @@ class representative { return account == other_a.account; } - nano::account account{ 0 }; + nano::account account{}; nano::amount weight{ 0 }; std::shared_ptr channel; std::chrono::steady_clock::time_point last_request{ std::chrono::steady_clock::time_point () }; diff --git a/nano/node/wallet.cpp b/nano/node/wallet.cpp index 2c4f36f773..7924aa2557 100644 --- a/nano/node/wallet.cpp +++ b/nano/node/wallet.cpp @@ -238,7 +238,7 @@ void nano::fan::value_set (nano::raw_key const & value_a) } // Wallet version number -nano::account const nano::wallet_store::version_special (0); +nano::account const nano::wallet_store::version_special{}; // Random number used to salt private key encryption nano::account const nano::wallet_store::salt_special (1); // Key used to encrypt wallet keys, encrypted itself by the user password @@ -714,7 +714,7 @@ bool nano::wallet::enter_password (nano::transaction const & transaction_a, std: nano::public_key nano::wallet::deterministic_insert (nano::transaction const & transaction_a, bool generate_work_a) { - nano::public_key key (0); + nano::public_key key{}; if (store.valid_password (transaction_a)) { key = store.deterministic_insert (transaction_a); @@ -735,7 +735,7 @@ nano::public_key nano::wallet::deterministic_insert (nano::transaction const & t nano::public_key nano::wallet::deterministic_insert (uint32_t const index, bool generate_work_a) { auto transaction (wallets.tx_begin_write ()); - nano::public_key key (0); + nano::public_key key{}; if (store.valid_password (transaction)) { key = store.deterministic_insert (transaction, index); @@ -756,7 +756,7 @@ nano::public_key nano::wallet::deterministic_insert (bool generate_work_a) nano::public_key nano::wallet::insert_adhoc (nano::raw_key const & key_a, bool generate_work_a) { - nano::public_key key (0); + nano::public_key key{}; auto transaction (wallets.tx_begin_write ()); if (store.valid_password (transaction)) { diff --git a/nano/node/websocket.cpp b/nano/node/websocket.cpp index 9f25f94432..92b23cc857 100644 --- a/nano/node/websocket.cpp +++ b/nano/node/websocket.cpp @@ -68,7 +68,7 @@ nano::websocket::confirmation_options::confirmation_options (boost::property_tre has_account_filtering_options = true; for (auto account_l : *accounts_l) { - nano::account result_l (0); + nano::account result_l{}; if (!result_l.decode_account (account_l.second.data ())) { // Do not insert the given raw data to keep old prefix support @@ -114,7 +114,8 @@ bool nano::websocket::confirmation_options::should_filter (nano::websocket::mess if (all_local_accounts) { auto transaction_l (wallets.tx_begin_read ()); - nano::account source_l (0), destination_l (0); + nano::account source_l{}; + nano::account destination_l{}; auto decode_source_ok_l (!source_l.decode_account (source_text_l)); auto decode_destination_ok_l (!destination_l.decode_account (destination_opt_l.get ())); (void)decode_source_ok_l; @@ -140,7 +141,7 @@ bool nano::websocket::confirmation_options::update (boost::property_tree::ptree this->has_account_filtering_options = true; for (auto const & account_l : accounts_text_a) { - nano::account result_l (0); + nano::account result_l{}; if (!result_l.decode_account (account_l.second.data ())) { // Re-encode to keep old prefix support @@ -197,7 +198,7 @@ nano::websocket::vote_options::vote_options (boost::property_tree::ptree const & { for (auto representative_l : *representatives_l) { - nano::account result_l (0); + nano::account result_l{}; if (!result_l.decode_account (representative_l.second.data ())) { // Do not insert the given raw data to keep old prefix support diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 536dcfc9b8..2489782449 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -494,7 +494,7 @@ TEST (rpc, send_idempotent) request.put ("wallet", wallet); request.put ("action", "send"); request.put ("source", nano::dev::genesis_key.pub.to_account ()); - request.put ("destination", nano::account (0).to_account ()); + request.put ("destination", nano::account{}.to_account ()); request.put ("amount", (nano::dev::constants.genesis_amount - (nano::dev::constants.genesis_amount / 4)).convert_to ()); request.put ("id", "123abc"); auto response (wait_response (system, rpc, request)); @@ -710,7 +710,7 @@ TEST (rpc, wallet_representative_set_force) auto transaction (node->wallets.tx_begin_read ()); ASSERT_EQ (key.pub, node->wallets.items.begin ()->second->store.representative (transaction)); } - nano::account representative (0); + nano::account representative{}; while (representative != key.pub) { auto transaction (node->store.tx_begin_read ()); @@ -1007,7 +1007,7 @@ TEST (rpc, frontier) auto [rpc, rpc_ctx] = add_rpc (system, node); boost::property_tree::ptree request; request.put ("action", "frontiers"); - request.put ("account", nano::account (0).to_account ()); + request.put ("account", nano::account{}.to_account ()); request.put ("count", std::to_string (std::numeric_limits::max ())); auto response (wait_response (system, rpc, request)); auto & frontiers_node (response.get_child ("frontiers")); @@ -1045,7 +1045,7 @@ TEST (rpc, frontier_limited) auto [rpc, rpc_ctx] = add_rpc (system, node); boost::property_tree::ptree request; request.put ("action", "frontiers"); - request.put ("account", nano::account (0).to_account ()); + request.put ("account", nano::account{}.to_account ()); request.put ("count", std::to_string (100)); auto response (wait_response (system, rpc, request)); auto & frontiers_node (response.get_child ("frontiers")); @@ -1859,16 +1859,15 @@ TEST (rpc, pending_burn) { nano::system system; auto node = add_ipc_enabled_node (system); - nano::account burn (0); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto block1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, burn, 100)); + auto block1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::constants.burn_account, 100)); auto [rpc, rpc_ctx] = add_rpc (system, node); node->scheduler.flush (); ASSERT_TIMELY (5s, !node->active.active (*block1)); ASSERT_TIMELY (5s, node->ledger.cache.cemented_count == 2 && node->confirmation_height_processor.current ().is_zero () && node->confirmation_height_processor.awaiting_processing_size () == 0); boost::property_tree::ptree request; request.put ("action", "pending"); - request.put ("account", burn.to_account ()); + request.put ("account", nano::dev::constants.burn_account.to_account ()); request.put ("count", "100"); { auto response (wait_response (system, rpc, request)); diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index b4391594bf..879c8925a7 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -38,7 +38,7 @@ char const * dev_genesis_data = R"%%%({ "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo", "work": "7b42a00ee91d5810", "signature": "ECDA914373A2F0CA1296475BAEE40500A7F0A7AD72A5A80C81D7FAB7F6C802B2CC7DB50F5DD0FB25B2EF11761FA7344A158DD5A700B21BD47DE5BD0F63153A02" - })%%%"; + })%%%"; char const * beta_genesis_data = R"%%%({ "type": "open", @@ -47,7 +47,7 @@ char const * beta_genesis_data = R"%%%({ "account": "nano_1betagoxpxwykx4kw86dnhosc8t3s7ix8eeentwkcg1hbpez1outjrcyg4n1", "work": "79d4e27dc873c6f2", "signature": "4BD7F96F9ED2721BCEE5EAED400EA50AD00524C629AE55E9AFF11220D2C1B00C3D4B3BB770BF67D4F8658023B677F91110193B6C101C2666931F57046A6DB806" - })%%%"; + })%%%"; char const * live_genesis_data = R"%%%({ "type": "open", @@ -56,7 +56,7 @@ char const * live_genesis_data = R"%%%({ "account": "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3", "work": "62f05417dd3fb691", "signature": "9F0C933C8ADE004D808EA1985FA746A7E95BA2A38F867640F53EC8F180BDFE9E2C1268DEAD7C2664F356E37ABA362BC58E46DBA03E523A7B5A19E4B6EB12BB02" - })%%%"; + })%%%"; std::string const test_genesis_data = nano::get_env_or_default ("NANO_TEST_GENESIS_BLOCK", R"%%%({ "type": "open", @@ -65,7 +65,7 @@ std::string const test_genesis_data = nano::get_env_or_default ("NANO_TEST_GENES "account": "nano_1jg8zygjg3pp5w644emqcbmjqpnzmubfni3kfe1s8pooeuxsw49fdq1mco9j", "work": "bc1ef279c1a34eb1", "signature": "15049467CAEE3EC768639E8E35792399B6078DA763DA4EBA8ECAD33B0EDC4AF2E7403893A5A602EB89B978DABEF1D6606BB00F3C0EE11449232B143B6E07170E" - })%%%"); + })%%%"); std::shared_ptr parse_block_from_genesis_data (std::string const & genesis_data_a) { @@ -115,7 +115,7 @@ nano::ledger_constants::ledger_constants (nano::work_thresholds & work, nano::ne : network_a == nano::networks::nano_test_network ? nano_test_genesis : nano_live_genesis), genesis_amount{ std::numeric_limits::max () }, - burn_account (0), + burn_account{}, nano_dev_final_votes_canary_account (dev_public_key_data), nano_beta_final_votes_canary_account (beta_canary_public_key_data), nano_live_final_votes_canary_account (live_canary_public_key_data), @@ -153,7 +153,15 @@ nano::ledger_constants::ledger_constants (nano::work_thresholds & work, nano::ne epochs.add (nano::epoch::epoch_2, epoch_v2_signer, epoch_link_v2); } -nano::random_constants::random_constants () +nano::hardened_constants & nano::hardened_constants::get () +{ + static hardened_constants instance{}; + return instance; +} + +nano::hardened_constants::hardened_constants () : + not_an_account{}, + random_128{} { nano::random_pool::generate_block (not_an_account.bytes.data (), not_an_account.bytes.size ()); nano::random_pool::generate_block (random_128.bytes.data (), random_128.bytes.size ()); diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 10c678c9d9..d42d5d0f49 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -72,9 +72,9 @@ struct hash<::nano::root> namespace nano { /** - * A key pair. The private key is generated from the random pool, or passed in - * as a hex string. The public key is derived using ed25519. - */ + * A key pair. The private key is generated from the random pool, or passed in + * as a hex string. The public key is derived using ed25519. + */ class keypair { public: @@ -86,8 +86,8 @@ class keypair }; /** - * Latest information about an account - */ + * Latest information about an account + */ class account_info final { public: @@ -99,7 +99,7 @@ class account_info final size_t db_size () const; nano::epoch epoch () const; nano::block_hash head{ 0 }; - nano::account representative{ 0 }; + nano::account representative{}; nano::block_hash open_block{ 0 }; nano::amount balance{ 0 }; /** Seconds since posix epoch */ @@ -109,8 +109,8 @@ class account_info final }; /** - * Information on an uncollected send - */ + * Information on an uncollected send + */ class pending_info final { public: @@ -119,7 +119,7 @@ class pending_info final size_t db_size () const; bool deserialize (nano::stream &); bool operator== (nano::pending_info const &) const; - nano::account source{ 0 }; + nano::account source{}; nano::amount amount{ 0 }; nano::epoch epoch{ nano::epoch::epoch_0 }; }; @@ -131,7 +131,7 @@ class pending_key final bool deserialize (nano::stream &); bool operator== (nano::pending_key const &) const; nano::account const & key () const; - nano::account account{ 0 }; + nano::account account{}; nano::block_hash hash{ 0 }; }; @@ -141,19 +141,19 @@ class endpoint_key final endpoint_key () = default; /* - * @param address_a This should be in network byte order - * @param port_a This should be in host byte order - */ + * @param address_a This should be in network byte order + * @param port_a This should be in host byte order + */ endpoint_key (const std::array & address_a, uint16_t port_a); /* - * @return The ipv6 address in network byte order - */ + * @return The ipv6 address in network byte order + */ const std::array & address_bytes () const; /* - * @return The port in host byte order - */ + * @return The port in host byte order + */ uint16_t port () const; private: @@ -181,8 +181,8 @@ class unchecked_key final }; /** - * Tag for block signature verification result - */ + * Tag for block signature verification result + */ enum class signature_verification : uint8_t { unknown = 0, @@ -192,8 +192,8 @@ enum class signature_verification : uint8_t }; /** - * Information on an unchecked block - */ + * Information on an unchecked block + */ class unchecked_info final { public: @@ -202,7 +202,7 @@ class unchecked_info final void serialize (nano::stream &) const; bool deserialize (nano::stream &); std::shared_ptr block; - nano::account account{ 0 }; + nano::account account{}; /** Seconds since posix epoch */ uint64_t modified{ 0 }; nano::signature_verification verified{ nano::signature_verification::unknown }; @@ -214,7 +214,7 @@ class block_info final public: block_info () = default; block_info (nano::account const &, nano::amount const &); - nano::account account{ 0 }; + nano::account account{}; nano::amount balance{ 0 }; }; @@ -275,8 +275,8 @@ class vote final static const std::string hash_prefix; }; /** - * This class serves to find and return unique variants of a vote in order to minimize memory usage - */ + * This class serves to find and return unique variants of a vote in order to minimize memory usage + */ class vote_uniquer final { public: @@ -374,13 +374,17 @@ namespace dev extern std::shared_ptr & genesis; } -/** Constants which depend on random values (this class should never be used globally due to CryptoPP globals potentially not being initialized) */ -class random_constants +/** Constants which depend on random values (always used as singleton) */ +class hardened_constants { public: - random_constants (); + static hardened_constants & get (); + nano::account not_an_account; nano::uint128_union random_128; + +private: + hardened_constants (); }; /** Node related constants whose value depends on the active network */ @@ -442,7 +446,6 @@ class network_params nano::work_thresholds work; nano::network_constants network; nano::ledger_constants ledger; - nano::random_constants random; nano::voting_constants voting; nano::node_constants node; nano::portmapping_constants portmapping; @@ -457,7 +460,7 @@ enum class confirmation_height_mode }; /* Holds flags for various cacheable data. For most CLI operations caching is unnecessary - * (e.g getting the cemented block count) so it can be disabled for performance reasons. */ + * (e.g getting the cemented block count) so it can be disabled for performance reasons. */ class generate_cache { public: diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index eb97206d79..8d96206ccc 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -116,7 +116,7 @@ class rollback_visitor : public nano::block_visitor } auto balance (ledger.balance (transaction, block_a.hashables.previous)); auto is_send (block_a.hashables.balance < balance); - nano::account representative{ 0 }; + nano::account representative{}; if (!rep_block_hash.is_zero ()) { // Move existing representation & add in amount delta @@ -958,8 +958,8 @@ nano::account const & nano::ledger::block_destination (nano::transaction const & { return state_block->hashables.link.as_account (); } - static nano::account result (0); - return result; + + return nano::account::null (); } nano::block_hash nano::ledger::block_source (nano::transaction const & transaction_a, nano::block const & block_a) @@ -1533,7 +1533,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (boost::filesystem::path const & data error |= rocksdb_store->account.get (rocksdb_transaction, account, account_info); // If confirmation height exists in the lmdb ledger for this account it should exist in the rocksdb ledger - nano::confirmation_height_info confirmation_height_info; + nano::confirmation_height_info confirmation_height_info{}; if (!store.confirmation_height.get (lmdb_transaction, account, confirmation_height_info)) { error |= rocksdb_store->confirmation_height.get (rocksdb_transaction, account, confirmation_height_info); diff --git a/nano/secure/store/frontier_store_partial.hpp b/nano/secure/store/frontier_store_partial.hpp index 9bec58444c..66d05cbeae 100644 --- a/nano/secure/store/frontier_store_partial.hpp +++ b/nano/secure/store/frontier_store_partial.hpp @@ -40,7 +40,7 @@ class frontier_store_partial : public frontier_store nano::db_val value; auto status (store.get (transaction_a, tables::frontiers, nano::db_val (block_a), value)); release_assert (store.success (status) || store.not_found (status)); - nano::account result (0); + nano::account result{}; if (store.success (status)) { result = static_cast (value); diff --git a/nano/secure/versioning.hpp b/nano/secure/versioning.hpp index 953ab410b9..429de22d97 100644 --- a/nano/secure/versioning.hpp +++ b/nano/secure/versioning.hpp @@ -15,7 +15,7 @@ class pending_info_v14 final size_t db_size () const; bool deserialize (nano::stream &); bool operator== (nano::pending_info_v14 const &) const; - nano::account source{ 0 }; + nano::account source{}; nano::amount amount{ 0 }; nano::epoch epoch{ nano::epoch::epoch_0 }; }; @@ -44,7 +44,7 @@ class block_sideband_v14 final static size_t size (nano::block_type); nano::block_type type{ nano::block_type::invalid }; nano::block_hash successor{ 0 }; - nano::account account{ 0 }; + nano::account account{}; nano::amount balance{ 0 }; uint64_t height{ 0 }; uint64_t timestamp{ 0 }; @@ -65,7 +65,7 @@ class block_sideband_v18 final bool deserialize (nano::stream &, nano::block_type); static size_t size (nano::block_type); nano::block_hash successor{ 0 }; - nano::account account{ 0 }; + nano::account account{}; nano::amount balance{ 0 }; uint64_t height{ 0 }; uint64_t timestamp{ 0 };