Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 9, 2023
1 parent d414c4c commit 7fa2e47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
16 changes: 6 additions & 10 deletions nano/secure/vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@

#include <boost/property_tree/json_parser.hpp>

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);
Expand All @@ -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<nano::block_hash> 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 ());
}
Expand Down Expand Up @@ -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");
Expand All @@ -183,6 +175,10 @@ bool nano::vote::is_final_timestamp (uint64_t timestamp)
return timestamp == std::numeric_limits<uint64_t>::max ();
}

/*
* iterate_vote_blocks_as_hash
*/

nano::block_hash nano::iterate_vote_blocks_as_hash::operator() (nano::block_hash const & item) const
{
return item;
Expand Down
22 changes: 11 additions & 11 deletions nano/secure/vote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nano::block_hash> const & hashes);

Expand Down Expand Up @@ -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<nano::block_hash> 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 };
};
}

0 comments on commit 7fa2e47

Please sign in to comment.