Serializing work as big-endian to match other numbers and also network byte order.
This commit is contained in:
parent
85d2ba9590
commit
1542fd4d79
2 changed files with 6 additions and 1 deletions
|
@ -341,6 +341,7 @@ TEST (state_block, serialization)
|
|||
rai::vectorstream stream (bytes);
|
||||
block1.serialize (stream);
|
||||
}
|
||||
ASSERT_EQ (0x5, bytes [215]); // Ensure work is serialized big-endian
|
||||
ASSERT_EQ (rai::state_block::size, bytes.size ());
|
||||
bool error1;
|
||||
rai::bufferstream stream (bytes.data (), bytes.size ());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include <rai/lib/blocks.hpp>
|
||||
|
||||
#include <boost/endian/conversion.hpp>
|
||||
|
||||
std::string rai::to_string_hex (uint64_t value_a)
|
||||
{
|
||||
std::stringstream stream;
|
||||
|
@ -919,6 +921,7 @@ hashables (error_a, stream_a)
|
|||
if (!error_a)
|
||||
{
|
||||
error_a = rai::read (stream_a, work);
|
||||
boost::endian::big_to_native_inplace (work);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -980,7 +983,7 @@ void rai::state_block::serialize (rai::stream & stream_a) const
|
|||
write (stream_a, hashables.balance);
|
||||
write (stream_a, hashables.link);
|
||||
write (stream_a, signature);
|
||||
write (stream_a, work);
|
||||
write (stream_a, boost::endian::native_to_big (work));
|
||||
}
|
||||
|
||||
void rai::state_block::serialize_json (std::string & string_a) const
|
||||
|
@ -1023,6 +1026,7 @@ bool rai::state_block::deserialize (rai::stream & stream_a)
|
|||
if (!error)
|
||||
{
|
||||
error = read (stream_a, work);
|
||||
boost::endian::big_to_native_inplace (work);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue