Skip to content

Commit

Permalink
Endianess fix for vote timestamp field (does not affect x86)
Browse files Browse the repository at this point in the history
This change will have no effect on little endianess machines (x86).
But it would fix big endian machines.
  • Loading branch information
dsiganos committed Oct 9, 2021
1 parent 1eefcaf commit 3a19a46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nano/secure/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ void nano::vote::serialize (nano::stream & stream_a, nano::block_type type) cons
{
write (stream_a, account);
write (stream_a, signature);
write (stream_a, timestamp);
write (stream_a, boost::endian::native_to_little (timestamp));
for (auto const & block : blocks)
{
if (block.which ())
Expand All @@ -662,7 +662,7 @@ void nano::vote::serialize (nano::stream & stream_a) const
{
write (stream_a, account);
write (stream_a, signature);
write (stream_a, timestamp);
write (stream_a, boost::endian::native_to_little (timestamp));
for (auto const & block : blocks)
{
if (block.which ())
Expand All @@ -685,6 +685,7 @@ bool nano::vote::deserialize (nano::stream & stream_a, nano::block_uniquer * uni
nano::read (stream_a, account);
nano::read (stream_a, signature);
nano::read (stream_a, timestamp);
boost::endian::little_to_native_inplace (timestamp);

nano::block_type type;

Expand Down

0 comments on commit 3a19a46

Please sign in to comment.