use FC for endian reversal to avoid Boost 1.58

This commit is contained in:
theoreticalbts 2015-07-02 15:04:43 -04:00
parent 29d4820fb9
commit 256b95ac5e
4 changed files with 10 additions and 8 deletions

View file

@ -56,7 +56,7 @@ IF( WIN32 )
set(BOOST_ALL_DYN_LINK OFF) # force dynamic linking for all libraries
ENDIF(WIN32)
FIND_PACKAGE(Boost 1.58 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
# For Boost 1.53 on windows, coroutine was not in BOOST_LIBRARYDIR and do not need it to build, but if boost versin >= 1.54, find coroutine otherwise will cause link errors
IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)")
SET(BOOST_LIBRARIES_TEMP ${Boost_LIBRARIES})

View file

@ -17,8 +17,7 @@
*/
#include <graphene/chain/block.hpp>
#include <fc/io/raw.hpp>
#include <boost/endian/conversion.hpp>
#include <fc/bitutil.hpp>
namespace graphene { namespace chain {
digest_type block_header::digest()const
@ -26,12 +25,15 @@ namespace graphene { namespace chain {
return digest_type::hash(*this);
}
uint32_t block_header::num_from_id(const block_id_type& id) { return boost::endian::endian_reverse(id._hash[0]); }
uint32_t block_header::num_from_id(const block_id_type& id)
{
return fc::endian_reverse_u32(id._hash[0]);
}
block_id_type signed_block_header::id()const
{
auto tmp = fc::sha224::hash( *this );
tmp._hash[0] = boost::endian::endian_reverse(block_num()); // store the block num in the ID, 160 bits is plenty for the hash
tmp._hash[0] = fc::endian_reverse_u32(block_num()); // store the block num in the ID, 160 bits is plenty for the hash
static_assert( sizeof(tmp._hash[0]) == 4, "should be 4 bytes" );
block_id_type result;
memcpy(result._hash, tmp._hash, std::min(sizeof(result), sizeof(tmp)));

View file

@ -17,7 +17,7 @@
*/
#include <graphene/chain/transaction.hpp>
#include <fc/io/raw.hpp>
#include <boost/endian/conversion.hpp>
#include <fc/bitutil.hpp>
namespace graphene { namespace chain {
@ -83,7 +83,7 @@ void transaction::set_expiration( fc::time_point_sec expiration_time )
void transaction::set_expiration( const block_id_type& reference_block, unsigned_int lifetime_intervals )
{
ref_block_num = boost::endian::endian_reverse(reference_block._hash[0]);
ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]);
ref_block_prefix = reference_block._hash[1];
relative_expiration = lifetime_intervals;
block_id_cache = reference_block;

@ -1 +1 @@
Subproject commit d462be0e92a576b93a83194e9649af528162bb4a
Subproject commit 443544be4f58f47e6432a2676ff81d8b782ce1b6