Cleanup unused member functions in secure library and various other cleanups (#1764)
* Initial changes * More changes
This commit is contained in:
parent
a0369e38d5
commit
ebdcdad19d
11 changed files with 72 additions and 304 deletions
|
@ -1588,7 +1588,7 @@ std::shared_ptr<nano::block> nano::block_uniquer::unique (std::shared_ptr<nano::
|
|||
existing = block_a;
|
||||
}
|
||||
release_assert (std::numeric_limits<CryptoPP::word32>::max () > blocks.size ());
|
||||
for (auto i (0); i < cleanup_count && blocks.size () > 0; ++i)
|
||||
for (auto i (0); i < cleanup_count && !blocks.empty (); ++i)
|
||||
{
|
||||
auto random_offset (nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (blocks.size () - 1)));
|
||||
auto existing (std::next (blocks.begin (), random_offset));
|
||||
|
|
|
@ -270,7 +270,7 @@ void nano::uint256_union::encode_dec (std::string & text) const
|
|||
|
||||
bool nano::uint256_union::decode_dec (std::string const & text)
|
||||
{
|
||||
auto error (text.size () > 78 || (text.size () > 1 && text[0] == '0') || (text.size () > 0 && text[0] == '-'));
|
||||
auto error (text.size () > 78 || (text.size () > 1 && text.front () == '0') || (!text.empty () && text.front () == '-'));
|
||||
if (!error)
|
||||
{
|
||||
std::stringstream stream (text);
|
||||
|
@ -540,7 +540,7 @@ void nano::uint128_union::encode_dec (std::string & text) const
|
|||
|
||||
bool nano::uint128_union::decode_dec (std::string const & text)
|
||||
{
|
||||
auto error (text.size () > 39 || (text.size () > 1 && text[0] == '0') || (text.size () > 0 && text[0] == '-'));
|
||||
auto error (text.size () > 39 || (text.size () > 1 && text.front () == '0') || (!text.empty () && text.front () == '-'));
|
||||
if (!error)
|
||||
{
|
||||
std::stringstream stream (text);
|
||||
|
|
|
@ -3121,7 +3121,7 @@ nano::tally_t nano::election::tally (nano::transaction const & transaction_a)
|
|||
void nano::election::confirm_if_quorum (nano::transaction const & transaction_a)
|
||||
{
|
||||
auto tally_l (tally (transaction_a));
|
||||
assert (tally_l.size () > 0);
|
||||
assert (!tally_l.empty ());
|
||||
auto winner (tally_l.begin ());
|
||||
auto block_l (winner->second);
|
||||
status.tally = winner->first;
|
||||
|
|
|
@ -392,7 +392,7 @@ nano::error nano::node_config::deserialize_json (bool & upgraded_a, nano::jsonco
|
|||
|
||||
nano::account nano::node_config::random_representative ()
|
||||
{
|
||||
assert (preconfigured_representatives.size () > 0);
|
||||
assert (!preconfigured_representatives.empty ());
|
||||
size_t index (nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (preconfigured_representatives.size () - 1)));
|
||||
auto result (preconfigured_representatives[index]);
|
||||
return result;
|
||||
|
|
|
@ -75,7 +75,6 @@ public:
|
|||
~payment_observer ();
|
||||
void start (uint64_t);
|
||||
void observe ();
|
||||
void timeout ();
|
||||
void complete (nano::payment_status);
|
||||
std::mutex mutex;
|
||||
std::condition_variable condition;
|
||||
|
@ -131,7 +130,6 @@ public:
|
|||
void delegators_count ();
|
||||
void deterministic_key ();
|
||||
void frontiers ();
|
||||
void history ();
|
||||
void keepalive ();
|
||||
void key_create ();
|
||||
void key_expand ();
|
||||
|
|
|
@ -293,7 +293,7 @@ void nano::stat::update (uint32_t key_a, uint64_t value)
|
|||
entry->samples.push_back (entry->sample_current);
|
||||
entry->sample_current.set_value (0);
|
||||
|
||||
if (entry->sample_observers.observers.size () > 0)
|
||||
if (!entry->sample_observers.observers.empty ())
|
||||
{
|
||||
auto snapshot (entry->samples);
|
||||
entry->sample_observers.notify (snapshot);
|
||||
|
|
|
@ -223,7 +223,7 @@ nano::uint128_t nano::summation_visitor::compute_internal (nano::summation_visit
|
|||
compiler optimizing that into a loop, though a future alternative is to do a
|
||||
CPS-style implementation to enforce tail calls.)
|
||||
*/
|
||||
while (frames.size () > 0)
|
||||
while (!frames.empty ())
|
||||
{
|
||||
current = &frames.top ();
|
||||
assert (current->type != summation_type::invalid && current != nullptr);
|
||||
|
@ -308,7 +308,7 @@ void nano::summation_visitor::epilogue ()
|
|||
if (!current->awaiting_result)
|
||||
{
|
||||
frames.pop ();
|
||||
if (frames.size () > 0)
|
||||
if (!frames.empty ())
|
||||
{
|
||||
frames.top ().incoming_result = current->sum;
|
||||
}
|
||||
|
|
|
@ -150,17 +150,6 @@ void nano::serialize_block (nano::stream & stream_a, nano::block const & block_a
|
|||
block_a.serialize (stream_a);
|
||||
}
|
||||
|
||||
nano::account_info::account_info () :
|
||||
head (0),
|
||||
rep_block (0),
|
||||
open_block (0),
|
||||
balance (0),
|
||||
modified (0),
|
||||
block_count (0),
|
||||
epoch (nano::epoch::epoch_0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::account_info::account_info (nano::block_hash const & head_a, nano::block_hash const & rep_block_a, nano::block_hash const & open_block_a, nano::amount const & balance_a, uint64_t modified_a, uint64_t block_count_a, nano::epoch epoch_a) :
|
||||
head (head_a),
|
||||
rep_block (rep_block_a),
|
||||
|
@ -172,16 +161,6 @@ epoch (epoch_a)
|
|||
{
|
||||
}
|
||||
|
||||
void nano::account_info::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
write (stream_a, head.bytes);
|
||||
write (stream_a, rep_block.bytes);
|
||||
write (stream_a, open_block.bytes);
|
||||
write (stream_a, balance.bytes);
|
||||
write (stream_a, modified);
|
||||
write (stream_a, block_count);
|
||||
}
|
||||
|
||||
bool nano::account_info::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
|
@ -223,28 +202,11 @@ size_t nano::account_info::db_size () const
|
|||
return sizeof (head) + sizeof (rep_block) + sizeof (open_block) + sizeof (balance) + sizeof (modified) + sizeof (block_count);
|
||||
}
|
||||
|
||||
nano::block_counts::block_counts () :
|
||||
send (0),
|
||||
receive (0),
|
||||
open (0),
|
||||
change (0),
|
||||
state_v0 (0),
|
||||
state_v1 (0)
|
||||
{
|
||||
}
|
||||
|
||||
size_t nano::block_counts::sum ()
|
||||
size_t nano::block_counts::sum () const
|
||||
{
|
||||
return send + receive + open + change + state_v0 + state_v1;
|
||||
}
|
||||
|
||||
nano::pending_info::pending_info () :
|
||||
source (0),
|
||||
amount (0),
|
||||
epoch (nano::epoch::epoch_0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::pending_info::pending_info (nano::account const & source_a, nano::amount const & amount_a, nano::epoch epoch_a) :
|
||||
source (source_a),
|
||||
amount (amount_a),
|
||||
|
@ -252,12 +214,6 @@ epoch (epoch_a)
|
|||
{
|
||||
}
|
||||
|
||||
void nano::pending_info::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
nano::write (stream_a, source.bytes);
|
||||
nano::write (stream_a, amount.bytes);
|
||||
}
|
||||
|
||||
bool nano::pending_info::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
|
@ -279,24 +235,12 @@ bool nano::pending_info::operator== (nano::pending_info const & other_a) const
|
|||
return source == other_a.source && amount == other_a.amount && epoch == other_a.epoch;
|
||||
}
|
||||
|
||||
nano::pending_key::pending_key () :
|
||||
account (0),
|
||||
hash (0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::pending_key::pending_key (nano::account const & account_a, nano::block_hash const & hash_a) :
|
||||
account (account_a),
|
||||
hash (hash_a)
|
||||
{
|
||||
}
|
||||
|
||||
void nano::pending_key::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
nano::write (stream_a, account.bytes);
|
||||
nano::write (stream_a, hash.bytes);
|
||||
}
|
||||
|
||||
bool nano::pending_key::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
|
@ -323,14 +267,6 @@ nano::block_hash nano::pending_key::key () const
|
|||
return account;
|
||||
}
|
||||
|
||||
nano::unchecked_info::unchecked_info () :
|
||||
block (nullptr),
|
||||
account (0),
|
||||
modified (0),
|
||||
verified (nano::signature_verification::unknown)
|
||||
{
|
||||
}
|
||||
|
||||
nano::unchecked_info::unchecked_info (std::shared_ptr<nano::block> block_a, nano::account const & account_a, uint64_t modified_a, nano::signature_verification verified_a) :
|
||||
block (block_a),
|
||||
account (account_a),
|
||||
|
@ -368,11 +304,6 @@ bool nano::unchecked_info::deserialize (nano::stream & stream_a)
|
|||
return error;
|
||||
}
|
||||
|
||||
bool nano::unchecked_info::operator== (nano::unchecked_info const & other_a) const
|
||||
{
|
||||
return block->hash () == other_a.block->hash () && account == other_a.account && modified == other_a.modified && verified == other_a.verified;
|
||||
}
|
||||
|
||||
nano::endpoint_key::endpoint_key (const std::array<uint8_t, 16> & address_a, uint16_t port_a) :
|
||||
address (address_a), network_port (boost::endian::native_to_big (port_a))
|
||||
{
|
||||
|
@ -388,45 +319,12 @@ uint16_t nano::endpoint_key::port () const
|
|||
return boost::endian::big_to_native (network_port);
|
||||
}
|
||||
|
||||
nano::block_info::block_info () :
|
||||
account (0),
|
||||
balance (0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::block_info::block_info (nano::account const & account_a, nano::amount const & balance_a) :
|
||||
account (account_a),
|
||||
balance (balance_a)
|
||||
{
|
||||
}
|
||||
|
||||
void nano::block_info::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
nano::write (stream_a, account.bytes);
|
||||
nano::write (stream_a, balance.bytes);
|
||||
}
|
||||
|
||||
bool nano::block_info::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
try
|
||||
{
|
||||
nano::read (stream_a, account.bytes);
|
||||
nano::read (stream_a, balance.bytes);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
bool nano::block_info::operator== (nano::block_info const & other_a) const
|
||||
{
|
||||
return account == other_a.account && balance == other_a.balance;
|
||||
}
|
||||
|
||||
bool nano::vote::operator== (nano::vote const & other_a) const
|
||||
{
|
||||
auto blocks_equal (true);
|
||||
|
@ -551,16 +449,14 @@ signature (nano::sign_message (prv_a, account_a, hash ()))
|
|||
{
|
||||
}
|
||||
|
||||
nano::vote::vote (nano::account const & account_a, nano::raw_key const & prv_a, uint64_t sequence_a, std::vector<nano::block_hash> blocks_a) :
|
||||
nano::vote::vote (nano::account const & account_a, nano::raw_key const & prv_a, uint64_t sequence_a, std::vector<nano::block_hash> const & blocks_a) :
|
||||
sequence (sequence_a),
|
||||
account (account_a)
|
||||
{
|
||||
assert (blocks_a.size () > 0);
|
||||
assert (!blocks_a.empty ());
|
||||
assert (blocks_a.size () <= 12);
|
||||
for (auto hash : blocks_a)
|
||||
{
|
||||
blocks.push_back (hash);
|
||||
}
|
||||
blocks.reserve (blocks_a.size ());
|
||||
std::copy (blocks_a.cbegin (), blocks_a.cend (), std::back_inserter (blocks));
|
||||
signature = nano::sign_message (prv_a, account_a, hash ());
|
||||
}
|
||||
|
||||
|
@ -582,7 +478,7 @@ nano::uint256_union nano::vote::hash () const
|
|||
nano::uint256_union result;
|
||||
blake2b_state hash;
|
||||
blake2b_init (&hash, sizeof (result.bytes));
|
||||
if (blocks.size () > 1 || (blocks.size () > 0 && blocks[0].which ()))
|
||||
if (blocks.size () > 1 || (!blocks.empty () && blocks.front ().which ()))
|
||||
{
|
||||
blake2b_update (&hash, hash_prefix.data (), hash_prefix.size ());
|
||||
}
|
||||
|
@ -613,12 +509,12 @@ nano::uint256_union nano::vote::full_hash () const
|
|||
return result;
|
||||
}
|
||||
|
||||
void nano::vote::serialize (nano::stream & stream_a, nano::block_type type)
|
||||
void nano::vote::serialize (nano::stream & stream_a, nano::block_type type) const
|
||||
{
|
||||
write (stream_a, account);
|
||||
write (stream_a, signature);
|
||||
write (stream_a, sequence);
|
||||
for (auto block : blocks)
|
||||
for (auto const & block : blocks)
|
||||
{
|
||||
if (block.which ())
|
||||
{
|
||||
|
@ -639,12 +535,12 @@ void nano::vote::serialize (nano::stream & stream_a, nano::block_type type)
|
|||
}
|
||||
}
|
||||
|
||||
void nano::vote::serialize (nano::stream & stream_a)
|
||||
void nano::vote::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
write (stream_a, account);
|
||||
write (stream_a, signature);
|
||||
write (stream_a, sequence);
|
||||
for (auto block : blocks)
|
||||
for (auto const & block : blocks)
|
||||
{
|
||||
if (block.which ())
|
||||
{
|
||||
|
@ -708,10 +604,9 @@ bool nano::vote::deserialize (nano::stream & stream_a, nano::block_uniquer * uni
|
|||
return error;
|
||||
}
|
||||
|
||||
bool nano::vote::validate ()
|
||||
bool nano::vote::validate () const
|
||||
{
|
||||
auto result (nano::validate_message (account, hash (), signature));
|
||||
return result;
|
||||
return nano::validate_message (account, hash (), signature);
|
||||
}
|
||||
|
||||
nano::block_hash nano::iterate_vote_blocks_as_hash::operator() (boost::variant<std::shared_ptr<nano::block>, nano::block_hash> const & item) const
|
||||
|
@ -748,9 +643,9 @@ std::shared_ptr<nano::vote> nano::vote_uniquer::unique (std::shared_ptr<nano::vo
|
|||
auto result (vote_a);
|
||||
if (result != nullptr && !result->blocks.empty ())
|
||||
{
|
||||
if (!result->blocks[0].which ())
|
||||
if (!result->blocks.front ().which ())
|
||||
{
|
||||
result->blocks[0] = uniquer.unique (boost::get<std::shared_ptr<nano::block>> (result->blocks[0]));
|
||||
result->blocks.front () = uniquer.unique (boost::get<std::shared_ptr<nano::block>> (result->blocks.front ()));
|
||||
}
|
||||
nano::uint256_union key (vote_a->full_hash ());
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
|
@ -765,7 +660,7 @@ std::shared_ptr<nano::vote> nano::vote_uniquer::unique (std::shared_ptr<nano::vo
|
|||
}
|
||||
|
||||
release_assert (std::numeric_limits<CryptoPP::word32>::max () > votes.size ());
|
||||
for (auto i (0); i < cleanup_count && votes.size () > 0; ++i)
|
||||
for (auto i (0); i < cleanup_count && !votes.empty (); ++i)
|
||||
{
|
||||
auto random_offset = nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (votes.size () - 1));
|
||||
|
||||
|
|
|
@ -78,22 +78,20 @@ enum class epoch : uint8_t
|
|||
class account_info
|
||||
{
|
||||
public:
|
||||
account_info ();
|
||||
account_info (nano::account_info const &) = default;
|
||||
account_info () = default;
|
||||
account_info (nano::block_hash const &, nano::block_hash const &, nano::block_hash const &, nano::amount const &, uint64_t, uint64_t, epoch);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::account_info const &) const;
|
||||
bool operator!= (nano::account_info const &) const;
|
||||
size_t db_size () const;
|
||||
nano::block_hash head;
|
||||
nano::block_hash rep_block;
|
||||
nano::block_hash open_block;
|
||||
nano::amount balance;
|
||||
nano::block_hash head{ 0 };
|
||||
nano::block_hash rep_block{ 0 };
|
||||
nano::block_hash open_block{ 0 };
|
||||
nano::amount balance{ 0 };
|
||||
/** Seconds since posix epoch */
|
||||
uint64_t modified;
|
||||
uint64_t block_count;
|
||||
nano::epoch epoch;
|
||||
uint64_t modified{ 0 };
|
||||
uint64_t block_count{ 0 };
|
||||
nano::epoch epoch{ nano::epoch::epoch_0 };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -102,26 +100,24 @@ public:
|
|||
class pending_info
|
||||
{
|
||||
public:
|
||||
pending_info ();
|
||||
pending_info () = default;
|
||||
pending_info (nano::account const &, nano::amount const &, epoch);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::pending_info const &) const;
|
||||
nano::account source;
|
||||
nano::amount amount;
|
||||
nano::epoch epoch;
|
||||
nano::account source{ 0 };
|
||||
nano::amount amount{ 0 };
|
||||
nano::epoch epoch{ nano::epoch::epoch_0 };
|
||||
};
|
||||
class pending_key
|
||||
{
|
||||
public:
|
||||
pending_key ();
|
||||
pending_key () = default;
|
||||
pending_key (nano::account const &, nano::block_hash const &);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::pending_key const &) const;
|
||||
nano::account account;
|
||||
nano::block_hash hash;
|
||||
nano::block_hash key () const;
|
||||
nano::account account{ 0 };
|
||||
nano::block_hash hash{ 0 };
|
||||
};
|
||||
|
||||
class endpoint_key
|
||||
|
@ -176,40 +172,35 @@ enum class signature_verification : uint8_t
|
|||
class unchecked_info
|
||||
{
|
||||
public:
|
||||
unchecked_info ();
|
||||
unchecked_info () = default;
|
||||
unchecked_info (std::shared_ptr<nano::block>, nano::account const &, uint64_t, nano::signature_verification = nano::signature_verification::unknown);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::unchecked_info const &) const;
|
||||
std::shared_ptr<nano::block> block;
|
||||
nano::account account;
|
||||
nano::account account{ 0 };
|
||||
/** Seconds since posix epoch */
|
||||
uint64_t modified;
|
||||
nano::signature_verification verified;
|
||||
uint64_t modified{ 0 };
|
||||
nano::signature_verification verified{ nano::signature_verification::unknown };
|
||||
};
|
||||
|
||||
class block_info
|
||||
{
|
||||
public:
|
||||
block_info ();
|
||||
block_info () = default;
|
||||
block_info (nano::account const &, nano::amount const &);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::block_info const &) const;
|
||||
nano::account account;
|
||||
nano::amount balance;
|
||||
nano::account account{ 0 };
|
||||
nano::amount balance{ 0 };
|
||||
};
|
||||
class block_counts
|
||||
{
|
||||
public:
|
||||
block_counts ();
|
||||
size_t sum ();
|
||||
size_t send;
|
||||
size_t receive;
|
||||
size_t open;
|
||||
size_t change;
|
||||
size_t state_v0;
|
||||
size_t state_v1;
|
||||
size_t sum () const;
|
||||
size_t send{ 0 };
|
||||
size_t receive{ 0 };
|
||||
size_t open{ 0 };
|
||||
size_t change{ 0 };
|
||||
size_t state_v0{ 0 };
|
||||
size_t state_v1{ 0 };
|
||||
};
|
||||
typedef std::vector<boost::variant<std::shared_ptr<nano::block>, nano::block_hash>>::const_iterator vote_blocks_vec_iter;
|
||||
class iterate_vote_blocks_as_hash
|
||||
|
@ -226,16 +217,16 @@ public:
|
|||
vote (bool &, nano::stream &, nano::block_uniquer * = nullptr);
|
||||
vote (bool &, nano::stream &, nano::block_type, nano::block_uniquer * = nullptr);
|
||||
vote (nano::account const &, nano::raw_key const &, uint64_t, std::shared_ptr<nano::block>);
|
||||
vote (nano::account const &, nano::raw_key const &, uint64_t, std::vector<nano::block_hash>);
|
||||
vote (nano::account const &, nano::raw_key const &, uint64_t, std::vector<nano::block_hash> const &);
|
||||
std::string hashes_string () const;
|
||||
nano::uint256_union hash () const;
|
||||
nano::uint256_union full_hash () const;
|
||||
bool operator== (nano::vote const &) const;
|
||||
bool operator!= (nano::vote const &) const;
|
||||
void serialize (nano::stream &, nano::block_type);
|
||||
void serialize (nano::stream &);
|
||||
void serialize (nano::stream &, nano::block_type) const;
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &, nano::block_uniquer * = nullptr);
|
||||
bool validate ();
|
||||
bool validate () const;
|
||||
boost::transform_iterator<nano::iterate_vote_blocks_as_hash, nano::vote_blocks_vec_iter> begin () const;
|
||||
boost::transform_iterator<nano::iterate_vote_blocks_as_hash, nano::vote_blocks_vec_iter> end () const;
|
||||
std::string to_json () const;
|
||||
|
@ -325,7 +316,7 @@ extern nano::account const & not_an_account ();
|
|||
class genesis
|
||||
{
|
||||
public:
|
||||
explicit genesis ();
|
||||
genesis ();
|
||||
nano::block_hash hash () const;
|
||||
std::shared_ptr<nano::block> open;
|
||||
};
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
#include <nano/secure/versioning.hpp>
|
||||
|
||||
nano::account_info_v1::account_info_v1 () :
|
||||
head (0),
|
||||
rep_block (0),
|
||||
balance (0),
|
||||
modified (0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::account_info_v1::account_info_v1 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -23,44 +15,11 @@ modified (modified_a)
|
|||
{
|
||||
}
|
||||
|
||||
void nano::account_info_v1::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
write (stream_a, head.bytes);
|
||||
write (stream_a, rep_block.bytes);
|
||||
write (stream_a, balance.bytes);
|
||||
write (stream_a, modified);
|
||||
}
|
||||
|
||||
bool nano::account_info_v1::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
try
|
||||
{
|
||||
read (stream_a, head.bytes);
|
||||
read (stream_a, rep_block.bytes);
|
||||
read (stream_a, balance.bytes);
|
||||
read (stream_a, modified);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
nano::mdb_val nano::account_info_v1::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::account_info_v1 *> (this));
|
||||
}
|
||||
|
||||
nano::pending_info_v3::pending_info_v3 () :
|
||||
source (0),
|
||||
amount (0),
|
||||
destination (0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::pending_info_v3::pending_info_v3 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -75,49 +34,11 @@ destination (destination_a)
|
|||
{
|
||||
}
|
||||
|
||||
void nano::pending_info_v3::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
nano::write (stream_a, source.bytes);
|
||||
nano::write (stream_a, amount.bytes);
|
||||
nano::write (stream_a, destination.bytes);
|
||||
}
|
||||
|
||||
bool nano::pending_info_v3::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
try
|
||||
{
|
||||
read (stream_a, source.bytes);
|
||||
read (stream_a, amount.bytes);
|
||||
read (stream_a, destination.bytes);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
bool nano::pending_info_v3::operator== (nano::pending_info_v3 const & other_a) const
|
||||
{
|
||||
return source == other_a.source && amount == other_a.amount && destination == other_a.destination;
|
||||
}
|
||||
|
||||
nano::mdb_val nano::pending_info_v3::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::pending_info_v3 *> (this));
|
||||
}
|
||||
|
||||
nano::account_info_v5::account_info_v5 () :
|
||||
head (0),
|
||||
rep_block (0),
|
||||
open_block (0),
|
||||
balance (0),
|
||||
modified (0)
|
||||
{
|
||||
}
|
||||
|
||||
nano::account_info_v5::account_info_v5 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -134,34 +55,6 @@ modified (modified_a)
|
|||
{
|
||||
}
|
||||
|
||||
void nano::account_info_v5::serialize (nano::stream & stream_a) const
|
||||
{
|
||||
write (stream_a, head.bytes);
|
||||
write (stream_a, rep_block.bytes);
|
||||
write (stream_a, open_block.bytes);
|
||||
write (stream_a, balance.bytes);
|
||||
write (stream_a, modified);
|
||||
}
|
||||
|
||||
bool nano::account_info_v5::deserialize (nano::stream & stream_a)
|
||||
{
|
||||
auto error (false);
|
||||
try
|
||||
{
|
||||
read (stream_a, head.bytes);
|
||||
read (stream_a, rep_block.bytes);
|
||||
read (stream_a, open_block.bytes);
|
||||
read (stream_a, balance.bytes);
|
||||
read (stream_a, modified);
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
nano::mdb_val nano::account_info_v5::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::account_info_v5 *> (this));
|
||||
|
|
|
@ -9,47 +9,38 @@ namespace nano
|
|||
class account_info_v1
|
||||
{
|
||||
public:
|
||||
account_info_v1 ();
|
||||
account_info_v1 () = default;
|
||||
account_info_v1 (MDB_val const &);
|
||||
account_info_v1 (nano::account_info_v1 const &) = default;
|
||||
account_info_v1 (nano::block_hash const &, nano::block_hash const &, nano::amount const &, uint64_t);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
nano::mdb_val val () const;
|
||||
nano::block_hash head;
|
||||
nano::block_hash rep_block;
|
||||
nano::amount balance;
|
||||
uint64_t modified;
|
||||
nano::block_hash head{ 0 };
|
||||
nano::block_hash rep_block{ 0 };
|
||||
nano::amount balance{ 0 };
|
||||
uint64_t modified{ 0 };
|
||||
};
|
||||
class pending_info_v3
|
||||
{
|
||||
public:
|
||||
pending_info_v3 ();
|
||||
pending_info_v3 () = default;
|
||||
pending_info_v3 (MDB_val const &);
|
||||
pending_info_v3 (nano::account const &, nano::amount const &, nano::account const &);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
bool operator== (nano::pending_info_v3 const &) const;
|
||||
nano::mdb_val val () const;
|
||||
nano::account source;
|
||||
nano::amount amount;
|
||||
nano::account destination;
|
||||
nano::account source{ 0 };
|
||||
nano::amount amount{ 0 };
|
||||
nano::account destination{ 0 };
|
||||
};
|
||||
// Latest information about an account
|
||||
class account_info_v5
|
||||
{
|
||||
public:
|
||||
account_info_v5 ();
|
||||
account_info_v5 () = default;
|
||||
account_info_v5 (MDB_val const &);
|
||||
account_info_v5 (nano::account_info_v5 const &) = default;
|
||||
account_info_v5 (nano::block_hash const &, nano::block_hash const &, nano::block_hash const &, nano::amount const &, uint64_t);
|
||||
void serialize (nano::stream &) const;
|
||||
bool deserialize (nano::stream &);
|
||||
nano::mdb_val val () const;
|
||||
nano::block_hash head;
|
||||
nano::block_hash rep_block;
|
||||
nano::block_hash open_block;
|
||||
nano::amount balance;
|
||||
uint64_t modified;
|
||||
nano::block_hash head{ 0 };
|
||||
nano::block_hash rep_block{ 0 };
|
||||
nano::block_hash open_block{ 0 };
|
||||
nano::amount balance{ 0 };
|
||||
uint64_t modified{ 0 };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue