From 7fa2e47088aaa2fe4eba9e5e1f168ca4f00809b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:25:55 +0100 Subject: [PATCH] Cleanup --- nano/secure/vote.cpp | 16 ++++++---------- nano/secure/vote.hpp | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/nano/secure/vote.cpp b/nano/secure/vote.cpp index 7da95cca87..2a7a669334 100644 --- a/nano/secure/vote.cpp +++ b/nano/secure/vote.cpp @@ -3,14 +3,6 @@ #include -nano::vote::vote (nano::vote const & other_a) : - timestamp_m{ other_a.timestamp_m }, - hashes{ other_a.hashes }, - account (other_a.account), - signature (other_a.signature) -{ -} - nano::vote::vote (bool & error_a, nano::stream & stream_a) { error_a = deserialize (stream_a); @@ -19,7 +11,7 @@ nano::vote::vote (bool & error_a, nano::stream & stream_a) nano::vote::vote (nano::account const & account_a, nano::raw_key const & prv_a, uint64_t timestamp_a, uint8_t duration, std::vector const & hashes) : hashes{ hashes }, timestamp_m{ packed_timestamp (timestamp_a, duration) }, - account (account_a) + account{ account_a } { signature = nano::sign_message (prv_a, account_a, hash ()); } @@ -171,7 +163,7 @@ std::string nano::vote::hashes_string () const return result; } -uint64_t nano::vote::packed_timestamp (uint64_t timestamp, uint8_t duration) const +uint64_t nano::vote::packed_timestamp (uint64_t timestamp, uint8_t duration) { debug_assert (duration <= duration_max && "Invalid duration"); debug_assert ((!(timestamp == timestamp_max) || (duration == duration_max)) && "Invalid final vote"); @@ -183,6 +175,10 @@ bool nano::vote::is_final_timestamp (uint64_t timestamp) return timestamp == std::numeric_limits::max (); } +/* + * iterate_vote_blocks_as_hash + */ + nano::block_hash nano::iterate_vote_blocks_as_hash::operator() (nano::block_hash const & item) const { return item; diff --git a/nano/secure/vote.hpp b/nano/secure/vote.hpp index 6dd4faf76d..b20fcb3671 100644 --- a/nano/secure/vote.hpp +++ b/nano/secure/vote.hpp @@ -23,7 +23,7 @@ class vote final { public: vote () = default; - vote (nano::vote const &); + vote (nano::vote const &) = default; vote (bool & error, nano::stream &); vote (nano::account const &, nano::raw_key const &, nano::millis_t timestamp, uint8_t duration, std::vector const & hashes); @@ -60,21 +60,21 @@ class vote final /* Check if timestamp represents a final vote */ static bool is_final_timestamp (uint64_t timestamp); -public: +private: + static std::string const hash_prefix; + + static uint64_t packed_timestamp (uint64_t timestamp, uint8_t duration); + +public: // Payload // The hashes for which this vote directly covers std::vector hashes; // Account that's voting - nano::account account; + nano::account account{ 0 }; // Signature of timestamp + block hashes - nano::signature signature; + nano::signature signature{ 0 }; -private: +private: // Payload // Vote timestamp - uint64_t timestamp_m; - -private: - static std::string const hash_prefix; - - uint64_t packed_timestamp (uint64_t timestamp, uint8_t duration) const; + uint64_t timestamp_m{ 0 }; }; } \ No newline at end of file