diff --git a/nano/secure/vote.cpp b/nano/secure/vote.cpp index 7da95cca87..4de1f1fe26 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,8 @@ 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{ 0 } { signature = nano::sign_message (prv_a, account_a, hash ()); } @@ -171,7 +164,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 +176,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..3058c540ec 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,7 +60,12 @@ 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 @@ -68,13 +73,8 @@ class vote final // Signature of timestamp + block hashes nano::signature signature; -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; }; } \ No newline at end of file