Progress auditing TODOs #108, upgrade boost 1.58
This commit is contained in:
parent
ae80339362
commit
8efa2e6738
12 changed files with 39 additions and 31 deletions
|
|
@ -56,7 +56,7 @@ IF( WIN32 )
|
|||
set(BOOST_ALL_DYN_LINK OFF) # force dynamic linking for all libraries
|
||||
ENDIF(WIN32)
|
||||
|
||||
FIND_PACKAGE(Boost 1.53 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||
FIND_PACKAGE(Boost 1.58 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})
|
||||
|
|
|
|||
|
|
@ -449,8 +449,7 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
|
|||
if( base.issuer == account_id_type() )
|
||||
{
|
||||
//It's a delegate-fed asset. Verify that publisher is an active delegate or witness.
|
||||
// TODO: replace account_id_type with global variable for delegates account id
|
||||
FC_ASSERT(d.get(account_id_type()).active.auths.count(o.publisher) ||
|
||||
FC_ASSERT(d.get(GRAPHENE_COMMITTEE_ACCOUNT).active.auths.count(o.publisher) ||
|
||||
d.get_global_properties().witness_accounts.count(o.publisher));
|
||||
} else {
|
||||
FC_ASSERT(bitasset.feeds.count(o.publisher));
|
||||
|
|
@ -464,14 +463,17 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope
|
|||
database& d = db();
|
||||
|
||||
const asset_object& base = o.asset_id(d);
|
||||
const asset_bitasset_data_object& bad = base.bitasset_data(d);
|
||||
|
||||
auto old_feed = bad.current_feed;
|
||||
// Store medians for this asset
|
||||
d.modify(base.bitasset_data(d), [&o,&d](asset_bitasset_data_object& a) {
|
||||
d.modify(bad , [&o,&d](asset_bitasset_data_object& a) {
|
||||
a.feeds[o.publisher] = make_pair(d.head_block_time(), o.feed);
|
||||
a.update_median_feeds(d.head_block_time());
|
||||
});
|
||||
|
||||
/// TODO: optimization: only do this if the median feed actually changed, otherwise there is no point
|
||||
db().check_call_orders(base);
|
||||
if( !(old_feed == bad.current_feed) )
|
||||
db().check_call_orders(base);
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <graphene/chain/block.hpp>
|
||||
#include <fc/io/raw.hpp>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
|
@ -25,10 +26,12 @@ 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]); }
|
||||
|
||||
block_id_type signed_block_header::id()const
|
||||
{
|
||||
auto tmp = fc::sha224::hash( *this );
|
||||
tmp._hash[0] = htonl(block_num()); // store the block num in the ID, 160 bits is plenty for the hash
|
||||
tmp._hash[0] = boost::endian::endian_reverse(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)));
|
||||
|
|
|
|||
|
|
@ -38,12 +38,6 @@ asset database::get_balance(const account_object& owner, const asset_object& ass
|
|||
return get_balance(owner.get_id(), asset_obj.get_id());
|
||||
}
|
||||
|
||||
// TODO: this method should be removed
|
||||
asset database::get_balance( const account_object* owner, const asset_object* asset_obj )const
|
||||
{
|
||||
return get_balance(*owner, *asset_obj);
|
||||
}
|
||||
|
||||
void database::adjust_balance(account_id_type account, asset delta )
|
||||
{ try {
|
||||
if( delta.amount == 0 )
|
||||
|
|
|
|||
|
|
@ -82,7 +82,10 @@ void database::debug_dump()
|
|||
{
|
||||
edump( (total_balances[asset_id_type()].value)(core_asset_data.current_supply.value ));
|
||||
}
|
||||
// TODO: Add vesting_balance_object to this method
|
||||
|
||||
const auto& vbidx = db.get_index_type<simple_index<vesting_balance_object>>();
|
||||
for( const auto& s : vbidx )
|
||||
idump(("vesting_balance")(s));
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@ void database::initialize_indexes()
|
|||
prop_index->add_secondary_index<required_approval_index>();
|
||||
|
||||
add_index< primary_index<withdraw_permission_index > >();
|
||||
add_index< primary_index<simple_index<vesting_balance_object> > >();
|
||||
//add_index< primary_index<vesting_balance_index> >();
|
||||
add_index< primary_index<simple_index<vesting_balance_object>> >();
|
||||
add_index< primary_index<worker_index> >();
|
||||
add_index< primary_index<balance_index> >();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace graphene { namespace chain {
|
|||
checksum_type transaction_merkle_root;
|
||||
vector<header_extension> extensions;
|
||||
|
||||
static uint32_t num_from_id(const block_id_type& id) { return htonl(id._hash[0]); }
|
||||
static uint32_t num_from_id(const block_id_type& id);
|
||||
};
|
||||
|
||||
struct signed_block_header : public block_header
|
||||
|
|
|
|||
|
|
@ -334,8 +334,6 @@ namespace graphene { namespace chain {
|
|||
asset get_balance(account_id_type owner, asset_id_type asset_id)const;
|
||||
/// This is an overloaded method.
|
||||
asset get_balance(const account_object& owner, const asset_object& asset_obj)const;
|
||||
/// This is an overloaded method.
|
||||
asset get_balance(const account_object* owner, const asset_object* asset_obj)const;
|
||||
|
||||
/**
|
||||
* @brief Adjust a particular account's balance in a given asset by a delta
|
||||
|
|
|
|||
|
|
@ -21,13 +21,6 @@
|
|||
|
||||
#include <numeric>
|
||||
|
||||
// this is for htonl() and ntohl() functions
|
||||
// TODO: write and use FC wrappers for these functions
|
||||
#ifndef WIN32
|
||||
#include <arpa/inet.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <graphene/chain/asset.hpp>
|
||||
#include <graphene/db/object.hpp>
|
||||
#include <graphene/db/generic_index.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
using namespace graphene::db;
|
||||
|
|
@ -156,6 +157,19 @@ namespace graphene { namespace chain {
|
|||
void withdraw(const fc::time_point_sec& now, const asset& amount);
|
||||
bool is_withdraw_allowed(const fc::time_point_sec& now, const asset& amount)const;
|
||||
};
|
||||
/**
|
||||
* @ingroup object_index
|
||||
*/
|
||||
typedef multi_index_container<
|
||||
vesting_balance_object,
|
||||
indexed_by<
|
||||
hashed_unique< tag<by_id>, member< object, object_id_type, &object::id > >
|
||||
>
|
||||
> vesting_balance_multi_index_type;
|
||||
/**
|
||||
* @ingroup object_index
|
||||
*/
|
||||
typedef generic_index<vesting_balance_object, vesting_balance_multi_index_type> vesting_balance_index;
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o
|
|||
if( _sell_asset->enforce_white_list() ) FC_ASSERT( _seller->is_authorized_asset( *_sell_asset ) );
|
||||
if( _receive_asset->enforce_white_list() ) FC_ASSERT( _seller->is_authorized_asset( *_receive_asset ) );
|
||||
|
||||
FC_ASSERT( d.get_balance( _seller, _sell_asset ) >= op.amount_to_sell, "insufficient balance",
|
||||
("balance",d.get_balance(_seller,_sell_asset))("amount_to_sell",op.amount_to_sell) );
|
||||
FC_ASSERT( d.get_balance( *_seller, *_sell_asset ) >= op.amount_to_sell, "insufficient balance",
|
||||
("balance",d.get_balance(*_seller,*_sell_asset))("amount_to_sell",op.amount_to_sell) );
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ void_result transfer_evaluator::do_evaluate( const transfer_operation& op )
|
|||
if( asset_type.is_transfer_restricted() )
|
||||
FC_ASSERT( from_account.id == asset_type.issuer || to_account.id == asset_type.issuer );
|
||||
|
||||
FC_ASSERT( d.get_balance( &from_account, &asset_type ).amount >= op.amount.amount,
|
||||
"", ("total_transfer",op.amount)("balance",d.get_balance(&from_account, &asset_type).amount) );
|
||||
FC_ASSERT( d.get_balance( from_account, asset_type ).amount >= op.amount.amount,
|
||||
"", ("total_transfer",op.amount)("balance",d.get_balance(from_account, asset_type).amount) );
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
@ -76,8 +76,8 @@ void_result override_transfer_evaluator::do_evaluate( const override_transfer_op
|
|||
if( fee_asset_type.options.flags & white_list )
|
||||
FC_ASSERT( from_account.is_authorized_asset( asset_type ) );
|
||||
|
||||
FC_ASSERT( d.get_balance( &from_account, &asset_type ).amount >= op.amount.amount,
|
||||
"", ("total_transfer",op.amount)("balance",d.get_balance(&from_account, &asset_type).amount) );
|
||||
FC_ASSERT( d.get_balance( from_account, asset_type ).amount >= op.amount.amount,
|
||||
"", ("total_transfer",op.amount)("balance",d.get_balance(from_account, asset_type).amount) );
|
||||
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
|
|
|||
Loading…
Reference in a new issue