Merge branch 'master' of github.com:cryptonomex/graphene
This commit is contained in:
commit
ed859277ef
38 changed files with 222 additions and 252 deletions
1
.gitmodules
vendored
1
.gitmodules
vendored
|
|
@ -1,6 +1,7 @@
|
||||||
[submodule "docs"]
|
[submodule "docs"]
|
||||||
path = docs
|
path = docs
|
||||||
url = https://github.com/cryptonomex/graphene.wiki.git
|
url = https://github.com/cryptonomex/graphene.wiki.git
|
||||||
|
ignore = dirty
|
||||||
[submodule "libraries/fc"]
|
[submodule "libraries/fc"]
|
||||||
path = libraries/fc
|
path = libraries/fc
|
||||||
url = https://github.com/cryptonomex/fc.git
|
url = https://github.com/cryptonomex/fc.git
|
||||||
|
|
|
||||||
2
docs
2
docs
|
|
@ -1 +1 @@
|
||||||
Subproject commit 71ed2984b71d57cab13cdf12074cff150edc1d3d
|
Subproject commit 94ec061b91edbe9d1ebae576e641f921998428c8
|
||||||
|
|
@ -113,7 +113,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
|
||||||
|
|
||||||
|
|
||||||
void_result account_update_evaluator::do_evaluate( const account_update_operation& o )
|
void_result account_update_evaluator::do_evaluate( const account_update_operation& o )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
const auto& chain_params = db().get_global_properties().parameters;
|
const auto& chain_params = db().get_global_properties().parameters;
|
||||||
|
|
@ -152,9 +152,10 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio
|
||||||
}
|
}
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result account_update_evaluator::do_apply( const account_update_operation& o )
|
void_result account_update_evaluator::do_apply( const account_update_operation& o )
|
||||||
{
|
{ try {
|
||||||
db().modify( *acnt, [&](account_object& a){
|
db().modify( *acnt, [&](account_object& a){
|
||||||
if( o.owner ) a.owner = resolve_relative_ids(*o.owner);
|
if( o.owner ) a.owner = resolve_relative_ids(*o.owner);
|
||||||
if( o.active ) a.active = resolve_relative_ids(*o.active);
|
if( o.active ) a.active = resolve_relative_ids(*o.active);
|
||||||
|
|
@ -165,7 +166,7 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result account_whitelist_evaluator::do_evaluate(const account_whitelist_operation& o)
|
void_result account_whitelist_evaluator::do_evaluate(const account_whitelist_operation& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -179,7 +180,7 @@ void_result account_whitelist_evaluator::do_evaluate(const account_whitelist_ope
|
||||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result account_whitelist_evaluator::do_apply(const account_whitelist_operation& o)
|
void_result account_whitelist_evaluator::do_apply(const account_whitelist_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
d.modify(*listed_account, [&o](account_object& a) {
|
d.modify(*listed_account, [&o](account_object& a) {
|
||||||
|
|
@ -194,20 +195,20 @@ void_result account_whitelist_evaluator::do_apply(const account_whitelist_operat
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result account_upgrade_evaluator::do_evaluate(const account_upgrade_evaluator::operation_type& o)
|
void_result account_upgrade_evaluator::do_evaluate(const account_upgrade_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
account = &d.get(o.account_to_upgrade);
|
account = &d.get(o.account_to_upgrade);
|
||||||
FC_ASSERT(!account->is_lifetime_member());
|
FC_ASSERT(!account->is_lifetime_member());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator::operation_type& o)
|
void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
d.modify(*account, [&](account_object& a) {
|
d.modify(*account, [&](account_object& a) {
|
||||||
|
|
@ -232,6 +233,6 @@ void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator:
|
||||||
});
|
});
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,12 @@ void account_statistics_object::process_fees(const account_object& a, database&
|
||||||
|
|
||||||
share_type network_cut = cut_fee(core_fee_total, account.network_fee_percentage);
|
share_type network_cut = cut_fee(core_fee_total, account.network_fee_percentage);
|
||||||
assert( network_cut <= core_fee_total );
|
assert( network_cut <= core_fee_total );
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
share_type burned = cut_fee(network_cut, props.parameters.burn_percent_of_fee);
|
share_type burned = cut_fee(network_cut, props.parameters.burn_percent_of_fee);
|
||||||
share_type accumulated = network_cut - burned;
|
share_type accumulated = network_cut - burned;
|
||||||
assert( accumulated + burned == network_cut );
|
assert( accumulated + burned == network_cut );
|
||||||
|
#endif
|
||||||
share_type lifetime_cut = cut_fee(core_fee_total, account.lifetime_referrer_fee_percentage);
|
share_type lifetime_cut = cut_fee(core_fee_total, account.lifetime_referrer_fee_percentage);
|
||||||
share_type referral = core_fee_total - network_cut - lifetime_cut;
|
share_type referral = core_fee_total - network_cut - lifetime_cut;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ struct predicate_evaluator
|
||||||
};
|
};
|
||||||
|
|
||||||
void_result assert_evaluator::do_evaluate( const assert_operation& o )
|
void_result assert_evaluator::do_evaluate( const assert_operation& o )
|
||||||
{
|
{ try {
|
||||||
const database& _db = db();
|
const database& _db = db();
|
||||||
uint32_t skip = _db.get_node_properties().skip_flags;
|
uint32_t skip = _db.get_node_properties().skip_flags;
|
||||||
auto max_predicate_opcode = _db.get_global_properties().parameters.max_predicate_opcode;
|
auto max_predicate_opcode = _db.get_global_properties().parameters.max_predicate_opcode;
|
||||||
|
|
@ -63,12 +63,12 @@ void_result assert_evaluator::do_evaluate( const assert_operation& o )
|
||||||
FC_ASSERT( p.visit( predicate_evaluator( _db ) ) );
|
FC_ASSERT( p.visit( predicate_evaluator( _db ) ) );
|
||||||
}
|
}
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result assert_evaluator::do_apply( const assert_operation& o )
|
void_result assert_evaluator::do_apply( const assert_operation& o )
|
||||||
{
|
{ try {
|
||||||
// assert_operation is always a no-op
|
// assert_operation is always a no-op
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -121,26 +121,9 @@ namespace graphene { namespace chain {
|
||||||
{ try {
|
{ try {
|
||||||
//wdump((debt)(collateral)(collateral_ratio));
|
//wdump((debt)(collateral)(collateral_ratio));
|
||||||
boost::rational<uint64_t> swan(debt.amount.value,collateral.amount.value);
|
boost::rational<uint64_t> swan(debt.amount.value,collateral.amount.value);
|
||||||
boost::rational<uint64_t> ratio( collateral_ratio, 1000 );
|
boost::rational<uint64_t> ratio( collateral_ratio, GRAPHENE_COLLATERAL_RATIO_DENOM );
|
||||||
auto cp = swan * ratio;
|
auto cp = swan * ratio;
|
||||||
return ~(asset( cp.numerator(), debt.asset_id ) / asset( cp.denominator(), collateral.asset_id ));
|
return ~(asset( cp.numerator(), debt.asset_id ) / asset( cp.denominator(), collateral.asset_id ));
|
||||||
|
|
||||||
/*
|
|
||||||
while( collateral.amount < 100000 && debt.amount < GRAPHENE_MAX_SHARE_SUPPLY/100 )
|
|
||||||
{
|
|
||||||
collateral.amount *= 1000;
|
|
||||||
debt.amount *= 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
fc::uint128 tmp( collateral.amount.value );
|
|
||||||
tmp *= 1000;
|
|
||||||
tmp /= collateral_ratio;
|
|
||||||
FC_ASSERT( tmp <= GRAPHENE_MAX_SHARE_SUPPLY );
|
|
||||||
asset col( tmp.to_uint64(), collateral.asset_id);
|
|
||||||
|
|
||||||
if( col.amount == 0 ) col.amount = 1;
|
|
||||||
return col / debt;
|
|
||||||
*/
|
|
||||||
} FC_CAPTURE_AND_RETHROW( (debt)(collateral)(collateral_ratio) ) }
|
} FC_CAPTURE_AND_RETHROW( (debt)(collateral)(collateral_ratio) ) }
|
||||||
|
|
||||||
bool price::is_null() const { return *this == price(); }
|
bool price::is_null() const { return *this == price(); }
|
||||||
|
|
@ -166,35 +149,9 @@ namespace graphene { namespace chain {
|
||||||
price price_feed::max_short_squeeze_price()const
|
price price_feed::max_short_squeeze_price()const
|
||||||
{
|
{
|
||||||
boost::rational<uint64_t> sp( settlement_price.base.amount.value, settlement_price.quote.amount.value ); //debt.amount.value,collateral.amount.value);
|
boost::rational<uint64_t> sp( settlement_price.base.amount.value, settlement_price.quote.amount.value ); //debt.amount.value,collateral.amount.value);
|
||||||
boost::rational<uint64_t> ratio( 1000, maximum_short_squeeze_ratio );
|
boost::rational<uint64_t> ratio( GRAPHENE_COLLATERAL_RATIO_DENOM, maximum_short_squeeze_ratio );
|
||||||
auto cp = sp * ratio;
|
auto cp = sp * ratio;
|
||||||
return (asset( cp.numerator(), settlement_price.base.asset_id ) / asset( cp.denominator(), settlement_price.quote.asset_id ));
|
return (asset( cp.numerator(), settlement_price.base.asset_id ) / asset( cp.denominator(), settlement_price.quote.asset_id ));
|
||||||
|
|
||||||
/*
|
|
||||||
asset collateral = settlement_price.quote;
|
|
||||||
fc::uint128 tmp( collateral.amount.value );
|
|
||||||
tmp *= maximum_short_squeeze_ratio;
|
|
||||||
tmp /= 1000;
|
|
||||||
FC_ASSERT( tmp <= GRAPHENE_MAX_SHARE_SUPPLY );
|
|
||||||
collateral.amount = tmp.to_uint64();
|
|
||||||
auto tmp2 = settlement_price.base / collateral;
|
|
||||||
wdump((rtn)(tmp2));
|
|
||||||
return rtn;
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
price price_feed::maintenance_price()const
|
|
||||||
{
|
|
||||||
asset collateral = settlement_price.quote;
|
|
||||||
fc::uint128 tmp( collateral.amount.value );
|
|
||||||
tmp *= maintenance_collateral_ratio;
|
|
||||||
tmp /= 1000;
|
|
||||||
FC_ASSERT( tmp <= GRAPHENE_MAX_SHARE_SUPPLY );
|
|
||||||
collateral.amount = tmp.to_uint64();
|
|
||||||
return settlement_price.base / collateral;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
object_id_type asset_create_evaluator::do_evaluate( const asset_create_operation& op )
|
void_result asset_create_evaluator::do_evaluate( const asset_create_operation& op )
|
||||||
{ try {
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
|
|
@ -59,11 +59,11 @@ object_id_type asset_create_evaluator::do_evaluate( const asset_create_operation
|
||||||
op.bitasset_options->force_settlement_delay_sec > chain_parameters.block_interval );
|
op.bitasset_options->force_settlement_delay_sec > chain_parameters.block_interval );
|
||||||
}
|
}
|
||||||
|
|
||||||
return object_id_type();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type asset_create_evaluator::do_apply( const asset_create_operation& op )
|
object_id_type asset_create_evaluator::do_apply( const asset_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
const asset_dynamic_data_object& dyn_asset =
|
const asset_dynamic_data_object& dyn_asset =
|
||||||
db().create<asset_dynamic_data_object>( [&]( asset_dynamic_data_object& a ) {
|
db().create<asset_dynamic_data_object>( [&]( asset_dynamic_data_object& a ) {
|
||||||
a.current_supply = 0;
|
a.current_supply = 0;
|
||||||
|
|
@ -95,8 +95,8 @@ object_id_type asset_create_evaluator::do_apply( const asset_create_operation& o
|
||||||
});
|
});
|
||||||
assert( new_asset.id == next_asset_id );
|
assert( new_asset.id == next_asset_id );
|
||||||
|
|
||||||
return next_asset_id;
|
return new_asset.id;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result asset_issue_evaluator::do_evaluate( const asset_issue_operation& o )
|
void_result asset_issue_evaluator::do_evaluate( const asset_issue_operation& o )
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -120,7 +120,7 @@ void_result asset_issue_evaluator::do_evaluate( const asset_issue_operation& o )
|
||||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_issue_evaluator::do_apply( const asset_issue_operation& o )
|
void_result asset_issue_evaluator::do_apply( const asset_issue_operation& o )
|
||||||
{
|
{ try {
|
||||||
db().adjust_balance( o.issue_to_account, o.asset_to_issue );
|
db().adjust_balance( o.issue_to_account, o.asset_to_issue );
|
||||||
|
|
||||||
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
||||||
|
|
@ -128,7 +128,7 @@ void_result asset_issue_evaluator::do_apply( const asset_issue_operation& o )
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_burn_evaluator::do_evaluate( const asset_burn_operation& o )
|
void_result asset_burn_evaluator::do_evaluate( const asset_burn_operation& o )
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -151,7 +151,7 @@ void_result asset_burn_evaluator::do_evaluate( const asset_burn_operation& o )
|
||||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_burn_evaluator::do_apply( const asset_burn_operation& o )
|
void_result asset_burn_evaluator::do_apply( const asset_burn_operation& o )
|
||||||
{
|
{ try {
|
||||||
db().adjust_balance( o.payer, -o.amount_to_burn );
|
db().adjust_balance( o.payer, -o.amount_to_burn );
|
||||||
|
|
||||||
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
||||||
|
|
@ -159,7 +159,7 @@ void_result asset_burn_evaluator::do_apply( const asset_burn_operation& o )
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_fund_fee_pool_evaluator::do_evaluate(const asset_fund_fee_pool_operation& o)
|
void_result asset_fund_fee_pool_evaluator::do_evaluate(const asset_fund_fee_pool_operation& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -173,7 +173,7 @@ void_result asset_fund_fee_pool_evaluator::do_evaluate(const asset_fund_fee_pool
|
||||||
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_operation& o)
|
void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_operation& o)
|
||||||
{
|
{ try {
|
||||||
db().adjust_balance(o.from_account, -o.amount);
|
db().adjust_balance(o.from_account, -o.amount);
|
||||||
|
|
||||||
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ) {
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ) {
|
||||||
|
|
@ -181,7 +181,7 @@ void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_op
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)
|
void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -214,7 +214,7 @@ void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)
|
||||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
||||||
|
|
||||||
void_result asset_update_evaluator::do_apply(const asset_update_operation& o)
|
void_result asset_update_evaluator::do_apply(const asset_update_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
// If we are now disabling force settlements, cancel all open force settlement orders
|
// If we are now disabling force settlements, cancel all open force settlement orders
|
||||||
|
|
@ -236,10 +236,10 @@ void_result asset_update_evaluator::do_apply(const asset_update_operation& o)
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bitasset_operation& o)
|
void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bitasset_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
const asset_object& a = o.asset_to_update(d);
|
const asset_object& a = o.asset_to_update(d);
|
||||||
|
|
@ -258,19 +258,19 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita
|
||||||
FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );
|
FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_update_bitasset_evaluator::do_apply(const asset_update_bitasset_operation& o)
|
void_result asset_update_bitasset_evaluator::do_apply(const asset_update_bitasset_operation& o)
|
||||||
{
|
{ try {
|
||||||
db().modify(*bitasset_to_update, [&o](asset_bitasset_data_object& b) {
|
db().modify(*bitasset_to_update, [&o](asset_bitasset_data_object& b) {
|
||||||
b.options = o.new_options;
|
b.options = o.new_options;
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_update_feed_producers_evaluator::operation_type& o)
|
void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_update_feed_producers_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
FC_ASSERT( o.new_feed_producers.size() <= d.get_global_properties().parameters.maximum_asset_feed_publishers );
|
FC_ASSERT( o.new_feed_producers.size() <= d.get_global_properties().parameters.maximum_asset_feed_publishers );
|
||||||
|
|
@ -286,10 +286,10 @@ void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_updat
|
||||||
bitasset_to_update = &b;
|
bitasset_to_update = &b;
|
||||||
FC_ASSERT( a.issuer == o.issuer );
|
FC_ASSERT( a.issuer == o.issuer );
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result asset_update_feed_producers_evaluator::do_apply(const asset_update_feed_producers_evaluator::operation_type& o)
|
void_result asset_update_feed_producers_evaluator::do_apply(const asset_update_feed_producers_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
db().modify(*bitasset_to_update, [&](asset_bitasset_data_object& a) {
|
db().modify(*bitasset_to_update, [&](asset_bitasset_data_object& a) {
|
||||||
//This is tricky because I have a set of publishers coming in, but a map of publisher to feed is stored.
|
//This is tricky because I have a set of publishers coming in, but a map of publisher to feed is stored.
|
||||||
//I need to update the map such that the keys match the new publishers, but not munge the old price feeds from
|
//I need to update the map such that the keys match the new publishers, but not munge the old price feeds from
|
||||||
|
|
@ -311,11 +311,10 @@ void_result asset_update_feed_producers_evaluator::do_apply(const asset_update_f
|
||||||
|
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
|
|
||||||
void_result asset_global_settle_evaluator::do_evaluate(const asset_global_settle_evaluator::operation_type& op)
|
void_result asset_global_settle_evaluator::do_evaluate(const asset_global_settle_evaluator::operation_type& op)
|
||||||
{
|
{ try {
|
||||||
const database& d = db();
|
const database& d = db();
|
||||||
asset_to_settle = &op.asset_to_settle(d);
|
asset_to_settle = &op.asset_to_settle(d);
|
||||||
FC_ASSERT(asset_to_settle->is_market_issued());
|
FC_ASSERT(asset_to_settle->is_market_issued());
|
||||||
|
|
@ -332,17 +331,17 @@ void_result asset_global_settle_evaluator::do_evaluate(const asset_global_settle
|
||||||
"Cannot force settle at supplied price: least collateralized short lacks sufficient collateral to settle.");
|
"Cannot force settle at supplied price: least collateralized short lacks sufficient collateral to settle.");
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result asset_global_settle_evaluator::do_apply(const asset_global_settle_evaluator::operation_type& op)
|
void_result asset_global_settle_evaluator::do_apply(const asset_global_settle_evaluator::operation_type& op)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
d.globally_settle_asset( op.asset_to_settle(db()), op.settle_price );
|
d.globally_settle_asset( op.asset_to_settle(db()), op.settle_price );
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type asset_settle_evaluator::do_evaluate(const asset_settle_evaluator::operation_type& op)
|
void_result asset_settle_evaluator::do_evaluate(const asset_settle_evaluator::operation_type& op)
|
||||||
{
|
{ try {
|
||||||
const database& d = db();
|
const database& d = db();
|
||||||
asset_to_settle = &op.amount.asset_id(d);
|
asset_to_settle = &op.amount.asset_id(d);
|
||||||
FC_ASSERT(asset_to_settle->is_market_issued());
|
FC_ASSERT(asset_to_settle->is_market_issued());
|
||||||
|
|
@ -352,11 +351,11 @@ object_id_type asset_settle_evaluator::do_evaluate(const asset_settle_evaluator:
|
||||||
FC_ASSERT( bitasset.has_settlement(), "global settlement must occur before force settling a prediction market" );
|
FC_ASSERT( bitasset.has_settlement(), "global settlement must occur before force settling a prediction market" );
|
||||||
FC_ASSERT(d.get_balance(d.get(op.account), *asset_to_settle) >= op.amount);
|
FC_ASSERT(d.get_balance(d.get(op.account), *asset_to_settle) >= op.amount);
|
||||||
|
|
||||||
return d.get_index_type<force_settlement_index>().get_next_id();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::operation_type& op)
|
operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::operation_type& op)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
d.adjust_balance(op.account, -op.amount);
|
d.adjust_balance(op.account, -op.amount);
|
||||||
|
|
||||||
|
|
@ -388,7 +387,7 @@ operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::
|
||||||
s.settlement_date = d.head_block_time() + asset_to_settle->bitasset_data(d).options.force_settlement_delay_sec;
|
s.settlement_date = d.head_block_time() + asset_to_settle->bitasset_data(d).options.force_settlement_delay_sec;
|
||||||
}).id;
|
}).id;
|
||||||
}
|
}
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_operation& o)
|
void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_operation& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -430,6 +429,6 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope
|
||||||
db().check_call_orders( base );
|
db().check_call_orders( base );
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void database::debug_dump()
|
||||||
total_balances[asset_obj.id] += asset_obj.dynamic_asset_data_id(db).accumulated_fees;
|
total_balances[asset_obj.id] += asset_obj.dynamic_asset_data_id(db).accumulated_fees;
|
||||||
total_balances[asset_id_type()] += asset_obj.dynamic_asset_data_id(db).fee_pool;
|
total_balances[asset_id_type()] += asset_obj.dynamic_asset_data_id(db).fee_pool;
|
||||||
}
|
}
|
||||||
for( const witness_object& witness_obj : db.get_index_type<simple_index<witness_object>>() )
|
for( const witness_object& witness_obj : db.get_index_type<witness_index>().indices() )
|
||||||
{
|
{
|
||||||
//idump((witness_obj));
|
//idump((witness_obj));
|
||||||
total_balances[asset_id_type()] += witness_obj.accumulated_income;
|
total_balances[asset_id_type()] += witness_obj.accumulated_income;
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,9 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize witness schedule
|
// Initialize witness schedule
|
||||||
|
#ifndef NDEBUG
|
||||||
const witness_schedule_object& wso =
|
const witness_schedule_object& wso =
|
||||||
|
#endif
|
||||||
create<witness_schedule_object>([&](witness_schedule_object& _wso)
|
create<witness_schedule_object>([&](witness_schedule_object& _wso)
|
||||||
{
|
{
|
||||||
memset(_wso.rng_seed.begin(), 0, _wso.rng_seed.size());
|
memset(_wso.rng_seed.begin(), 0, _wso.rng_seed.size());
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,15 @@
|
||||||
#include <graphene/chain/account_object.hpp>
|
#include <graphene/chain/account_object.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
object_id_type delegate_create_evaluator::do_evaluate( const delegate_create_operation& op )
|
|
||||||
{
|
void_result delegate_create_evaluator::do_evaluate( const delegate_create_operation& op )
|
||||||
|
{ try {
|
||||||
FC_ASSERT(db().get(op.delegate_account).is_lifetime_member());
|
FC_ASSERT(db().get(op.delegate_account).is_lifetime_member());
|
||||||
return object_id_type();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type delegate_create_evaluator::do_apply( const delegate_create_operation& op )
|
object_id_type delegate_create_evaluator::do_apply( const delegate_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
vote_id_type vote_id;
|
vote_id_type vote_id;
|
||||||
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
|
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
|
||||||
vote_id = p.get_next_vote_id(vote_id_type::committee);
|
vote_id = p.get_next_vote_id(vote_id_type::committee);
|
||||||
|
|
@ -40,6 +41,6 @@ object_id_type delegate_create_evaluator::do_apply( const delegate_create_operat
|
||||||
obj.vote_id = vote_id;
|
obj.vote_id = vote_id;
|
||||||
});
|
});
|
||||||
return new_del_object.id;
|
return new_del_object.id;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,19 @@
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
void_result global_parameters_update_evaluator::do_evaluate(const global_parameters_update_operation& o)
|
void_result global_parameters_update_evaluator::do_evaluate(const global_parameters_update_operation& o)
|
||||||
{
|
{ try {
|
||||||
FC_ASSERT(trx_state->_is_proposed_trx);
|
FC_ASSERT(trx_state->_is_proposed_trx);
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result global_parameters_update_evaluator::do_apply(const global_parameters_update_operation& o)
|
void_result global_parameters_update_evaluator::do_apply(const global_parameters_update_operation& o)
|
||||||
{
|
{ try {
|
||||||
db().modify(db().get_global_properties(), [&o](global_property_object& p) {
|
db().modify(db().get_global_properties(), [&o](global_property_object& p) {
|
||||||
p.pending_parameters = o.new_parameters;
|
p.pending_parameters = o.new_parameters;
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace graphene { namespace chain {
|
||||||
/**
|
/**
|
||||||
* Required maintenance collateral is defined
|
* Required maintenance collateral is defined
|
||||||
* as a fixed point number with a maximum value of 10.000
|
* as a fixed point number with a maximum value of 10.000
|
||||||
* and a minimum value of 1.000. (denominated in 1000)
|
* and a minimum value of 1.000. (denominated in GRAPHENE_COLLATERAL_RATIO_DENOM)
|
||||||
*
|
*
|
||||||
* A black swan event occurs when value_of_collateral equals
|
* A black swan event occurs when value_of_collateral equals
|
||||||
* value_of_debt, to avoid a black swan a margin call is
|
* value_of_debt, to avoid a black swan a margin call is
|
||||||
|
|
@ -145,10 +145,10 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
price settlement_price;
|
price settlement_price;
|
||||||
|
|
||||||
/** Fixed point between 1.000 and 10.000, implied fixed point denominator is 1000 */
|
/** Fixed point between 1.000 and 10.000, implied fixed point denominator is GRAPHENE_COLLATERAL_RATIO_DENOM */
|
||||||
uint16_t maintenance_collateral_ratio = GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO;
|
uint16_t maintenance_collateral_ratio = GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO;
|
||||||
|
|
||||||
/** Fixed point between 1.000 and 10.000, implied fixed point denominator is 1000 */
|
/** Fixed point between 1.000 and 10.000, implied fixed point denominator is GRAPHENE_COLLATERAL_RATIO_DENOM */
|
||||||
uint16_t maximum_short_squeeze_ratio = GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO;
|
uint16_t maximum_short_squeeze_ratio = GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef asset_create_operation operation_type;
|
typedef asset_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const asset_create_operation& o );
|
void_result do_evaluate( const asset_create_operation& o );
|
||||||
object_id_type do_apply( const asset_create_operation& o );
|
object_id_type do_apply( const asset_create_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef asset_settle_operation operation_type;
|
typedef asset_settle_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate(const operation_type& op);
|
void_result do_evaluate(const operation_type& op);
|
||||||
operation_result do_apply(const operation_type& op);
|
operation_result do_apply(const operation_type& op);
|
||||||
|
|
||||||
const asset_object* asset_to_settle = nullptr;
|
const asset_object* asset_to_settle = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,12 @@
|
||||||
#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10
|
#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These ratios are fixed point numbers with a denominator of 1000, the
|
* These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the
|
||||||
* minimum maitenance collateral is therefore 1.001x and the default
|
* minimum maitenance collateral is therefore 1.001x and the default
|
||||||
* maintenance ratio is 1.75x
|
* maintenance ratio is 1.75x
|
||||||
*/
|
*/
|
||||||
///@{
|
///@{
|
||||||
|
#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000
|
||||||
#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0
|
#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0
|
||||||
#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage
|
#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage
|
||||||
#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt
|
#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef delegate_create_operation operation_type;
|
typedef delegate_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const delegate_create_operation& o );
|
void_result do_evaluate( const delegate_create_operation& o );
|
||||||
object_id_type do_apply( const delegate_create_operation& o );
|
object_id_type do_apply( const delegate_create_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef limit_order_create_operation operation_type;
|
typedef limit_order_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const limit_order_create_operation& o );
|
void_result do_evaluate( const limit_order_create_operation& o );
|
||||||
object_id_type do_apply( const limit_order_create_operation& o );
|
object_id_type do_apply( const limit_order_create_operation& o );
|
||||||
|
|
||||||
asset calculate_market_fee( const asset_object* aobj, const asset& trade_amount );
|
asset calculate_market_fee( const asset_object* aobj, const asset& trade_amount );
|
||||||
|
|
@ -43,7 +43,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef limit_order_cancel_operation operation_type;
|
typedef limit_order_cancel_operation operation_type;
|
||||||
|
|
||||||
asset do_evaluate( const limit_order_cancel_operation& o );
|
void_result do_evaluate( const limit_order_cancel_operation& o );
|
||||||
asset do_apply( const limit_order_cancel_operation& o );
|
asset do_apply( const limit_order_cancel_operation& o );
|
||||||
|
|
||||||
const limit_order_object* _order;
|
const limit_order_object* _order;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef proposal_create_operation operation_type;
|
typedef proposal_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const proposal_create_operation& o );
|
void_result do_evaluate( const proposal_create_operation& o );
|
||||||
object_id_type do_apply( const proposal_create_operation& o );
|
object_id_type do_apply( const proposal_create_operation& o );
|
||||||
|
|
||||||
transaction _proposed_trx;
|
transaction _proposed_trx;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class vesting_balance_create_evaluator : public evaluator<vesting_balance_create
|
||||||
public:
|
public:
|
||||||
typedef vesting_balance_create_operation operation_type;
|
typedef vesting_balance_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const vesting_balance_create_operation& op );
|
void_result do_evaluate( const vesting_balance_create_operation& op );
|
||||||
object_id_type do_apply( const vesting_balance_create_operation& op );
|
object_id_type do_apply( const vesting_balance_create_operation& op );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class withdraw_permission_create_evaluator : public evaluator<withdraw_permissio
|
||||||
public:
|
public:
|
||||||
typedef withdraw_permission_create_operation operation_type;
|
typedef withdraw_permission_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const operation_type& op );
|
void_result do_evaluate( const operation_type& op );
|
||||||
object_id_type do_apply( const operation_type& op );
|
object_id_type do_apply( const operation_type& op );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef witness_create_operation operation_type;
|
typedef witness_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const witness_create_operation& o );
|
void_result do_evaluate( const witness_create_operation& o );
|
||||||
object_id_type do_apply( const witness_create_operation& o );
|
object_id_type do_apply( const witness_create_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ class generic_witness_scheduler
|
||||||
public:
|
public:
|
||||||
void check_invariant() const
|
void check_invariant() const
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
CountType tokens = _ineligible_no_turn.size() + _eligible.size();
|
CountType tokens = _ineligible_no_turn.size() + _eligible.size();
|
||||||
CountType turns = _eligible.size();
|
CountType turns = _eligible.size();
|
||||||
for( const std::pair< WitnessID, bool >& item : _ineligible_waiting_for_token )
|
for( const std::pair< WitnessID, bool >& item : _ineligible_waiting_for_token )
|
||||||
|
|
@ -47,7 +48,7 @@ class generic_witness_scheduler
|
||||||
|
|
||||||
assert( _tokens == tokens );
|
assert( _tokens == tokens );
|
||||||
assert( _turns == turns );
|
assert( _turns == turns );
|
||||||
|
#endif
|
||||||
|
|
||||||
flat_set< WitnessID > witness_set;
|
flat_set< WitnessID > witness_set;
|
||||||
// make sure each witness_id occurs only once among the three states
|
// make sure each witness_id occurs only once among the three states
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace graphene { namespace chain {
|
||||||
public:
|
public:
|
||||||
typedef worker_create_operation operation_type;
|
typedef worker_create_operation operation_type;
|
||||||
|
|
||||||
object_id_type do_evaluate( const operation_type& o );
|
void_result do_evaluate( const operation_type& o );
|
||||||
object_id_type do_apply( const operation_type& o );
|
object_id_type do_apply( const operation_type& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
#include <fc/uint128.hpp>
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
object_id_type limit_order_create_evaluator::do_evaluate( const limit_order_create_operation& op )
|
void_result limit_order_create_evaluator::do_evaluate( const limit_order_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
FC_ASSERT( op.expiration >= d.head_block_time() );
|
FC_ASSERT( op.expiration >= d.head_block_time() );
|
||||||
|
|
@ -42,13 +42,11 @@ object_id_type limit_order_create_evaluator::do_evaluate( const limit_order_crea
|
||||||
FC_ASSERT( d.get_balance( _seller, _sell_asset ) >= op.amount_to_sell, "insufficient balance",
|
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) );
|
("balance",d.get_balance(_seller,_sell_asset))("amount_to_sell",op.amount_to_sell) );
|
||||||
|
|
||||||
return object_id_type();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
template<typename I>
|
|
||||||
std::reverse_iterator<I> reverse( const I& itr ) { return std::reverse_iterator<I>(itr); }
|
|
||||||
|
|
||||||
object_id_type limit_order_create_evaluator::do_apply( const limit_order_create_operation& op )
|
object_id_type limit_order_create_evaluator::do_apply( const limit_order_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
const auto& seller_stats = _seller->statistics(db());
|
const auto& seller_stats = _seller->statistics(db());
|
||||||
db().modify( seller_stats, [&]( account_statistics_object& bal ){
|
db().modify( seller_stats, [&]( account_statistics_object& bal ){
|
||||||
if( op.amount_to_sell.asset_id == asset_id_type() )
|
if( op.amount_to_sell.asset_id == asset_id_type() )
|
||||||
|
|
@ -120,23 +118,21 @@ object_id_type limit_order_create_evaluator::do_apply( const limit_order_create_
|
||||||
FC_ASSERT( !op.fill_or_kill || db().find_object(result) == nullptr );
|
FC_ASSERT( !op.fill_or_kill || db().find_object(result) == nullptr );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} // limit_order_evaluator::do_apply
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
asset limit_order_cancel_evaluator::do_evaluate( const limit_order_cancel_operation& o )
|
void_result limit_order_cancel_evaluator::do_evaluate( const limit_order_cancel_operation& o )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
_order = &o.order(d);
|
_order = &o.order(d);
|
||||||
FC_ASSERT( _order->seller == o.fee_paying_account );
|
FC_ASSERT( _order->seller == o.fee_paying_account );
|
||||||
auto refunded = _order->amount_for_sale();
|
|
||||||
//adjust_balance( fee_paying_account, &refunded.asset_id(d), refunded.amount );
|
|
||||||
|
|
||||||
return refunded;
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
asset limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation& o )
|
asset limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation& o )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
auto base_asset = _order->sell_price.base.asset_id;
|
auto base_asset = _order->sell_price.base.asset_id;
|
||||||
auto quote_asset = _order->sell_price.quote.asset_id;
|
auto quote_asset = _order->sell_price.quote.asset_id;
|
||||||
|
|
@ -150,5 +146,6 @@ asset limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation
|
||||||
db().check_call_orders(quote_asset(d));
|
db().check_call_orders(quote_asset(d));
|
||||||
|
|
||||||
return refunded;
|
return refunded;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
object_id_type proposal_create_evaluator::do_evaluate(const proposal_create_operation& o)
|
void_result proposal_create_evaluator::do_evaluate(const proposal_create_operation& o)
|
||||||
{
|
{ try {
|
||||||
const database& d = db();
|
const database& d = db();
|
||||||
const auto& global_parameters = d.get_global_properties().parameters;
|
const auto& global_parameters = d.get_global_properties().parameters;
|
||||||
|
|
||||||
|
|
@ -47,11 +47,11 @@ object_id_type proposal_create_evaluator::do_evaluate(const proposal_create_oper
|
||||||
_proposed_trx.operations.push_back(op.op);
|
_proposed_trx.operations.push_back(op.op);
|
||||||
_proposed_trx.validate();
|
_proposed_trx.validate();
|
||||||
|
|
||||||
return object_id_type();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
object_id_type proposal_create_evaluator::do_apply(const proposal_create_operation& o)
|
object_id_type proposal_create_evaluator::do_apply(const proposal_create_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
const proposal_object& proposal = d.create<proposal_object>([&](proposal_object& proposal) {
|
const proposal_object& proposal = d.create<proposal_object>([&](proposal_object& proposal) {
|
||||||
|
|
@ -71,10 +71,10 @@ object_id_type proposal_create_evaluator::do_apply(const proposal_create_operati
|
||||||
});
|
});
|
||||||
|
|
||||||
return proposal.id;
|
return proposal.id;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result proposal_update_evaluator::do_evaluate(const proposal_update_operation& o)
|
void_result proposal_update_evaluator::do_evaluate(const proposal_update_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
_proposal = &o.proposal(d);
|
_proposal = &o.proposal(d);
|
||||||
|
|
@ -106,10 +106,10 @@ void_result proposal_update_evaluator::do_evaluate(const proposal_update_operati
|
||||||
}
|
}
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result proposal_update_evaluator::do_apply(const proposal_update_operation& o)
|
void_result proposal_update_evaluator::do_apply(const proposal_update_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
// Potential optimization: if _executed_proposal is true, we can skip the modify step and make push_proposal skip
|
// Potential optimization: if _executed_proposal is true, we can skip the modify step and make push_proposal skip
|
||||||
|
|
@ -147,10 +147,10 @@ void_result proposal_update_evaluator::do_apply(const proposal_update_operation&
|
||||||
}
|
}
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result proposal_delete_evaluator::do_evaluate(const proposal_delete_operation& o)
|
void_result proposal_delete_evaluator::do_evaluate(const proposal_delete_operation& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
_proposal = &o.proposal(d);
|
_proposal = &o.proposal(d);
|
||||||
|
|
@ -162,13 +162,13 @@ void_result proposal_delete_evaluator::do_evaluate(const proposal_delete_operati
|
||||||
("provided", o.fee_paying_account)("required", *required_approvals));
|
("provided", o.fee_paying_account)("required", *required_approvals));
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result proposal_delete_evaluator::do_apply(const proposal_delete_operation&)
|
void_result proposal_delete_evaluator::do_apply(const proposal_delete_operation& o)
|
||||||
{
|
{ try {
|
||||||
db().remove(*_proposal);
|
db().remove(*_proposal);
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,6 @@ void_result transfer_evaluator::do_apply( const transfer_operation& o )
|
||||||
db().adjust_balance( o.from, -o.amount );
|
db().adjust_balance( o.from, -o.amount );
|
||||||
db().adjust_balance( o.to, o.amount );
|
db().adjust_balance( o.to, o.amount );
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (o) )}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
object_id_type vesting_balance_create_evaluator::do_evaluate( const vesting_balance_create_operation& op )
|
void_result vesting_balance_create_evaluator::do_evaluate( const vesting_balance_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
const database& d = db();
|
const database& d = db();
|
||||||
|
|
||||||
const account_object& creator_account = op.creator( d );
|
const account_object& creator_account = op.creator( d );
|
||||||
|
|
@ -36,8 +36,8 @@ object_id_type vesting_balance_create_evaluator::do_evaluate( const vesting_bala
|
||||||
FC_ASSERT( d.get_balance( creator_account.id, op.amount.asset_id ) >= op.amount );
|
FC_ASSERT( d.get_balance( creator_account.id, op.amount.asset_id ) >= op.amount );
|
||||||
FC_ASSERT( !op.amount.asset_id(d).is_transfer_restricted() );
|
FC_ASSERT( !op.amount.asset_id(d).is_transfer_restricted() );
|
||||||
|
|
||||||
return object_id_type();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
struct init_policy_visitor
|
struct init_policy_visitor
|
||||||
{
|
{
|
||||||
|
|
@ -73,7 +73,7 @@ struct init_policy_visitor
|
||||||
};
|
};
|
||||||
|
|
||||||
object_id_type vesting_balance_create_evaluator::do_apply( const vesting_balance_create_operation& op )
|
object_id_type vesting_balance_create_evaluator::do_apply( const vesting_balance_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
const time_point_sec now = d.head_block_time();
|
const time_point_sec now = d.head_block_time();
|
||||||
|
|
||||||
|
|
@ -91,10 +91,10 @@ object_id_type vesting_balance_create_evaluator::do_apply( const vesting_balance
|
||||||
|
|
||||||
|
|
||||||
return vbo.id;
|
return vbo.id;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result vesting_balance_withdraw_evaluator::do_evaluate( const vesting_balance_withdraw_operation& op )
|
void_result vesting_balance_withdraw_evaluator::do_evaluate( const vesting_balance_withdraw_operation& op )
|
||||||
{
|
{ try {
|
||||||
const database& d = db();
|
const database& d = db();
|
||||||
const time_point_sec now = d.head_block_time();
|
const time_point_sec now = d.head_block_time();
|
||||||
|
|
||||||
|
|
@ -106,10 +106,10 @@ void_result vesting_balance_withdraw_evaluator::do_evaluate( const vesting_balan
|
||||||
/* const account_object& owner_account = */ op.owner( d );
|
/* const account_object& owner_account = */ op.owner( d );
|
||||||
// TODO: Check asset authorizations and withdrawals
|
// TODO: Check asset authorizations and withdrawals
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result vesting_balance_withdraw_evaluator::do_apply( const vesting_balance_withdraw_operation& op )
|
void_result vesting_balance_withdraw_evaluator::do_apply( const vesting_balance_withdraw_operation& op )
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
const time_point_sec now = d.head_block_time();
|
const time_point_sec now = d.head_block_time();
|
||||||
|
|
||||||
|
|
@ -128,6 +128,6 @@ void_result vesting_balance_withdraw_evaluator::do_apply( const vesting_balance_
|
||||||
|
|
||||||
// TODO: Check asset authorizations and withdrawals
|
// TODO: Check asset authorizations and withdrawals
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
object_id_type withdraw_permission_create_evaluator::do_evaluate(const operation_type& op)
|
void_result withdraw_permission_create_evaluator::do_evaluate(const operation_type& op)
|
||||||
{ try {
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
FC_ASSERT(d.find_object(op.withdraw_from_account));
|
FC_ASSERT(d.find_object(op.withdraw_from_account));
|
||||||
|
|
@ -32,7 +32,7 @@ object_id_type withdraw_permission_create_evaluator::do_evaluate(const operation
|
||||||
FC_ASSERT(op.period_start_time + op.periods_until_expiration * op.withdrawal_period_sec > d.head_block_time());
|
FC_ASSERT(op.period_start_time + op.periods_until_expiration * op.withdrawal_period_sec > d.head_block_time());
|
||||||
FC_ASSERT(op.withdrawal_period_sec >= d.get_global_properties().parameters.block_interval);
|
FC_ASSERT(op.withdrawal_period_sec >= d.get_global_properties().parameters.block_interval);
|
||||||
|
|
||||||
return d.get_index_type<withdraw_permission_index>().get_next_id();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type withdraw_permission_create_evaluator::do_apply(const operation_type& op)
|
object_id_type withdraw_permission_create_evaluator::do_apply(const operation_type& op)
|
||||||
|
|
@ -133,9 +133,9 @@ void_result withdraw_permission_delete_evaluator::do_evaluate(const withdraw_per
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result withdraw_permission_delete_evaluator::do_apply(const withdraw_permission_delete_evaluator::operation_type& op)
|
void_result withdraw_permission_delete_evaluator::do_apply(const withdraw_permission_delete_evaluator::operation_type& op)
|
||||||
{
|
{ try {
|
||||||
db().remove(db().get(op.withdrawal_permission));
|
db().remove(db().get(op.withdrawal_permission));
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,15 @@
|
||||||
#include <graphene/chain/database.hpp>
|
#include <graphene/chain/database.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
object_id_type witness_create_evaluator::do_evaluate( const witness_create_operation& op )
|
|
||||||
{
|
void_result witness_create_evaluator::do_evaluate( const witness_create_operation& op )
|
||||||
|
{ try {
|
||||||
FC_ASSERT(db().get(op.witness_account).is_lifetime_member());
|
FC_ASSERT(db().get(op.witness_account).is_lifetime_member());
|
||||||
return object_id_type();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
object_id_type witness_create_evaluator::do_apply( const witness_create_operation& op )
|
object_id_type witness_create_evaluator::do_apply( const witness_create_operation& op )
|
||||||
{
|
{ try {
|
||||||
vote_id_type vote_id;
|
vote_id_type vote_id;
|
||||||
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
|
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
|
||||||
vote_id = p.get_next_vote_id(vote_id_type::witness);
|
vote_id = p.get_next_vote_id(vote_id_type::witness);
|
||||||
|
|
@ -43,10 +44,10 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio
|
||||||
obj.next_secret = op.initial_secret;
|
obj.next_secret = op.initial_secret;
|
||||||
});
|
});
|
||||||
return new_witness_object.id;
|
return new_witness_object.id;
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result witness_withdraw_pay_evaluator::do_evaluate(const witness_withdraw_pay_evaluator::operation_type& o)
|
void_result witness_withdraw_pay_evaluator::do_evaluate(const witness_withdraw_pay_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
witness = &d.get(o.from_witness);
|
witness = &d.get(o.from_witness);
|
||||||
|
|
@ -56,10 +57,10 @@ void_result witness_withdraw_pay_evaluator::do_evaluate(const witness_withdraw_p
|
||||||
to_account = &d.get(o.to_account);
|
to_account = &d.get(o.to_account);
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
void_result witness_withdraw_pay_evaluator::do_apply(const witness_withdraw_pay_evaluator::operation_type& o)
|
void_result witness_withdraw_pay_evaluator::do_apply(const witness_withdraw_pay_evaluator::operation_type& o)
|
||||||
{
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
d.adjust_balance(o.to_account, asset(o.amount));
|
d.adjust_balance(o.to_account, asset(o.amount));
|
||||||
|
|
@ -69,6 +70,6 @@ void_result witness_withdraw_pay_evaluator::do_apply(const witness_withdraw_pay_
|
||||||
});
|
});
|
||||||
|
|
||||||
return void_result();
|
return void_result();
|
||||||
}
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
object_id_type worker_create_evaluator::do_evaluate(const worker_create_evaluator::operation_type& o)
|
void_result worker_create_evaluator::do_evaluate(const worker_create_evaluator::operation_type& o)
|
||||||
{ try {
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
FC_ASSERT(d.get(o.owner).is_lifetime_member());
|
FC_ASSERT(d.get(o.owner).is_lifetime_member());
|
||||||
FC_ASSERT(o.work_begin_date >= d.head_block_time());
|
FC_ASSERT(o.work_begin_date >= d.head_block_time());
|
||||||
|
|
||||||
return object_id_type();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator::operation_type& o)
|
object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator::operation_type& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
@ -51,6 +51,6 @@ object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator::
|
||||||
w.worker.set_which(o.initializer.which());
|
w.worker.set_which(o.initializer.which());
|
||||||
w.worker.visit(worker_initialize_visitor(w, o.initializer, d));
|
w.worker.visit(worker_initialize_visitor(w, o.initializer, d));
|
||||||
}).id;
|
}).id;
|
||||||
} FC_CAPTURE_AND_RETHROW((o)) }
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a8b85f6dcc4558b7a9913b59ef5dc19f3b5e62ca
|
Subproject commit 701b9ac00c46234ee7cc6385027f5942590debc9
|
||||||
|
|
@ -2,11 +2,12 @@ add_executable( cli_wallet main.cpp )
|
||||||
if( UNIX AND NOT APPLE )
|
if( UNIX AND NOT APPLE )
|
||||||
set(rt_library rt )
|
set(rt_library rt )
|
||||||
endif()
|
endif()
|
||||||
#find_package( Gperftools QUIET )
|
|
||||||
#if( GPERFTOOLS_FOUND )
|
find_package( Gperftools QUIET )
|
||||||
# message( STATUS "Found gperftools; compiling client with TCMalloc")
|
if( GPERFTOOLS_FOUND )
|
||||||
# list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
message( STATUS "Found gperftools; compiling cli_wallet with TCMalloc")
|
||||||
#endif()
|
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries( cli_wallet
|
target_link_libraries( cli_wallet
|
||||||
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ int main( int argc, char** argv )
|
||||||
ac.rotate = true;
|
ac.rotate = true;
|
||||||
ac.rotation_interval = fc::hours( 1 );
|
ac.rotation_interval = fc::hours( 1 );
|
||||||
ac.rotation_limit = fc::days( 1 );
|
ac.rotation_limit = fc::days( 1 );
|
||||||
ac.rotation_compression = false;
|
|
||||||
|
|
||||||
std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n";
|
std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,6 @@ add_executable( field_reflector main.cpp )
|
||||||
if( UNIX AND NOT APPLE )
|
if( UNIX AND NOT APPLE )
|
||||||
set(rt_library rt )
|
set(rt_library rt )
|
||||||
endif()
|
endif()
|
||||||
#find_package( Gperftools QUIET )
|
|
||||||
#if( GPERFTOOLS_FOUND )
|
|
||||||
# message( STATUS "Found gperftools; compiling client with TCMalloc")
|
|
||||||
# list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
target_link_libraries( field_reflector
|
target_link_libraries( field_reflector
|
||||||
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,6 @@ add_executable( js_operation_serializer main.cpp )
|
||||||
if( UNIX AND NOT APPLE )
|
if( UNIX AND NOT APPLE )
|
||||||
set(rt_library rt )
|
set(rt_library rt )
|
||||||
endif()
|
endif()
|
||||||
#find_package( Gperftools QUIET )
|
|
||||||
#if( GPERFTOOLS_FOUND )
|
|
||||||
# message( STATUS "Found gperftools; compiling client with TCMalloc")
|
|
||||||
# list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
target_link_libraries( js_operation_serializer
|
target_link_libraries( js_operation_serializer
|
||||||
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
PRIVATE graphene_app graphene_net graphene_chain graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,12 @@ add_executable( witness_node main.cpp )
|
||||||
if( UNIX AND NOT APPLE )
|
if( UNIX AND NOT APPLE )
|
||||||
set(rt_library rt )
|
set(rt_library rt )
|
||||||
endif()
|
endif()
|
||||||
#find_package( Gperftools QUIET )
|
|
||||||
#if( GPERFTOOLS_FOUND )
|
find_package( Gperftools QUIET )
|
||||||
# message( STATUS "Found gperftools; compiling client with TCMalloc")
|
if( GPERFTOOLS_FOUND )
|
||||||
# list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
message( STATUS "Found gperftools; compiling witness_node with TCMalloc")
|
||||||
#endif()
|
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries( witness_node
|
target_link_libraries( witness_node
|
||||||
PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,27 @@
|
||||||
file(GLOB COMMON_SOURCES "common/*.cpp")
|
file(GLOB COMMON_SOURCES "common/*.cpp")
|
||||||
|
|
||||||
|
find_package( Gperftools QUIET )
|
||||||
|
if( GPERFTOOLS_FOUND )
|
||||||
|
message( STATUS "Found gperftools; compiling tests with TCMalloc")
|
||||||
|
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB UNIT_TESTS "tests/*.cpp")
|
file(GLOB UNIT_TESTS "tests/*.cpp")
|
||||||
add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} )
|
add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} )
|
||||||
target_link_libraries( chain_test graphene_chain graphene_app graphene_account_history fc )
|
target_link_libraries( chain_test graphene_chain graphene_app graphene_account_history fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
||||||
file(GLOB PERFORMANCE_TESTS "performance/*.cpp")
|
file(GLOB PERFORMANCE_TESTS "performance/*.cpp")
|
||||||
add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} )
|
add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} )
|
||||||
target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history fc )
|
target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
||||||
file(GLOB BENCH_MARKS "benchmarks/*.cpp")
|
file(GLOB BENCH_MARKS "benchmarks/*.cpp")
|
||||||
add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} )
|
add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} )
|
||||||
target_link_libraries( chain_bench graphene_chain graphene_account_history graphene_time fc )
|
target_link_libraries( chain_bench graphene_chain graphene_account_history graphene_time fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
||||||
file(GLOB APP_SOURCES "app/*.cpp")
|
file(GLOB APP_SOURCES "app/*.cpp")
|
||||||
add_executable( app_test ${APP_SOURCES} )
|
add_executable( app_test ${APP_SOURCES} )
|
||||||
target_link_libraries( app_test graphene_account_history graphene_app graphene_net graphene_chain graphene_time fc )
|
target_link_libraries( app_test graphene_account_history graphene_app graphene_net graphene_chain graphene_time fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
||||||
file(GLOB INTENSE_SOURCES "intense/*.cpp")
|
file(GLOB INTENSE_SOURCES "intense/*.cpp")
|
||||||
add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} )
|
add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} )
|
||||||
target_link_libraries( intense_test graphene_chain graphene_app graphene_account_history fc )
|
target_link_libraries( intense_test graphene_chain graphene_app graphene_account_history fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE( black_swan )
|
||||||
publish_feed( bitusd, feedproducer, current_feed );
|
publish_feed( bitusd, feedproducer, current_feed );
|
||||||
|
|
||||||
/// this sell order is designed to trigger a black swan
|
/// this sell order is designed to trigger a black swan
|
||||||
create_sell_order(borrower2, bitusd.amount(1000), core.amount(3000));
|
create_sell_order( borrower2, bitusd.amount(1000), core.amount(3000) );
|
||||||
|
|
||||||
FC_ASSERT( bitusd.bitasset_data(db).has_settlement() );
|
FC_ASSERT( bitusd.bitasset_data(db).has_settlement() );
|
||||||
|
|
||||||
|
|
@ -1283,33 +1283,6 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test )
|
||||||
BOOST_CHECK_EQUAL(witness->accumulated_income.value, 0);
|
BOOST_CHECK_EQUAL(witness->accumulated_income.value, 0);
|
||||||
} FC_LOG_AND_RETHROW() }
|
} FC_LOG_AND_RETHROW() }
|
||||||
|
|
||||||
/**
|
|
||||||
* This test should simulate a prediction market which means the following:
|
|
||||||
*
|
|
||||||
* 1) Issue a BitAsset without Forced Settling & With Global Settling
|
|
||||||
* 2) Don't Publish any Price Feeds
|
|
||||||
* 3) Ensure that margin calls do not occur even if the highest bid would indicate it
|
|
||||||
* 4) Match some Orders
|
|
||||||
* 5) Trigger Global Settle on the Asset
|
|
||||||
* 6) The maintenance collateral must always be 1:1
|
|
||||||
*/
|
|
||||||
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( unimp_prediction_market_test, 1 )
|
|
||||||
BOOST_AUTO_TEST_CASE( unimp_prediction_market_test )
|
|
||||||
{
|
|
||||||
BOOST_FAIL( "not implemented" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This test should verify that the asset_global_settle operation works as expected,
|
|
||||||
* make sure that global settling cannot be performed by anyone other than the
|
|
||||||
* issuer and only if the global settle bit is set.
|
|
||||||
*/
|
|
||||||
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( unimp_global_settle_test_2, 1 )
|
|
||||||
BOOST_AUTO_TEST_CASE( unimp_global_settle_test_2 )
|
|
||||||
{
|
|
||||||
BOOST_FAIL( "not implemented" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asset Burn Test should make sure that all assets except bitassets
|
* Asset Burn Test should make sure that all assets except bitassets
|
||||||
* can be burned and all supplies add up.
|
* can be burned and all supplies add up.
|
||||||
|
|
|
||||||
|
|
@ -437,29 +437,62 @@ BOOST_AUTO_TEST_CASE( witness_create )
|
||||||
generate_block(0, nathan_private_key);
|
generate_block(0, nathan_private_key);
|
||||||
} FC_LOG_AND_RETHROW() }
|
} FC_LOG_AND_RETHROW() }
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( unimp_global_settle_test, 1 )
|
/**
|
||||||
BOOST_AUTO_TEST_CASE( unimp_global_settle_test )
|
* This test should verify that the asset_global_settle operation works as expected,
|
||||||
|
* make sure that global settling cannot be performed by anyone other than the
|
||||||
|
* issuer and only if the global settle bit is set.
|
||||||
|
*/
|
||||||
|
BOOST_AUTO_TEST_CASE( global_settle_test )
|
||||||
{
|
{
|
||||||
BOOST_FAIL( "TODO - Reimplement this" );
|
|
||||||
/*
|
|
||||||
try {
|
try {
|
||||||
ACTORS((nathan)(ben)(valentine)(dan));
|
ACTORS((nathan)(ben)(valentine)(dan));
|
||||||
asset_id_type bit_usd_id = create_bitasset("BITUSD", nathan_id, 100, global_settle | charge_market_fee).get_id();
|
asset_id_type bit_usd_id = create_bitasset("BITUSD", nathan_id, 100, global_settle | charge_market_fee).get_id();
|
||||||
|
|
||||||
|
update_feed_producers( bit_usd_id(db), { nathan_id } );
|
||||||
|
|
||||||
|
price_feed feed;
|
||||||
|
feed.settlement_price = price( asset( 1000, bit_usd_id ), asset( 500 ) );
|
||||||
|
feed.maintenance_collateral_ratio = 175 * GRAPHENE_COLLATERAL_RATIO_DENOM / 100;
|
||||||
|
feed.maximum_short_squeeze_ratio = 150 * GRAPHENE_COLLATERAL_RATIO_DENOM / 100;
|
||||||
|
publish_feed( bit_usd_id(db), nathan, feed );
|
||||||
|
|
||||||
transfer(genesis_account, ben_id, asset(10000));
|
transfer(genesis_account, ben_id, asset(10000));
|
||||||
transfer(genesis_account, valentine_id, asset(10000));
|
transfer(genesis_account, valentine_id, asset(10000));
|
||||||
transfer(genesis_account, dan_id, asset(10000));
|
transfer(genesis_account, dan_id, asset(10000));
|
||||||
create_short(ben_id, asset(1000, bit_usd_id), asset(1000));
|
borrow(ben, asset(1000, bit_usd_id), asset(1000));
|
||||||
create_sell_order(valentine_id, asset(1000), asset(1000, bit_usd_id));
|
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 1000);
|
||||||
create_short(valentine_id, asset(500, bit_usd_id), asset(600));
|
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000);
|
||||||
create_sell_order(dan_id, asset(600), asset(500, bit_usd_id));
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 990);
|
create_sell_order(ben_id, asset(1000, bit_usd_id), asset(1000));
|
||||||
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 8400);
|
|
||||||
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
||||||
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000);
|
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000);
|
||||||
|
|
||||||
|
create_sell_order(valentine_id, asset(1000), asset(1000, bit_usd_id));
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 10000);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 990);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 9000);
|
||||||
|
|
||||||
|
borrow(valentine, asset(500, bit_usd_id), asset(600));
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 1490);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 8400);
|
||||||
|
|
||||||
|
create_sell_order(valentine_id, asset(500, bit_usd_id), asset(600));
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 990);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 8400);
|
||||||
|
|
||||||
|
create_sell_order(dan_id, asset(600), asset(500, bit_usd_id));
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 990);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 9000);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 10000);
|
||||||
BOOST_CHECK_EQUAL(get_balance(dan_id, bit_usd_id), 495);
|
BOOST_CHECK_EQUAL(get_balance(dan_id, bit_usd_id), 495);
|
||||||
BOOST_CHECK_EQUAL(get_balance(dan_id, asset_id_type()), 9400);
|
BOOST_CHECK_EQUAL(get_balance(dan_id, asset_id_type()), 9400);
|
||||||
|
|
||||||
|
// add some collateral
|
||||||
|
borrow(ben, asset(0, bit_usd_id), asset(1000));
|
||||||
|
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000);
|
||||||
|
|
||||||
{
|
{
|
||||||
asset_global_settle_operation op;
|
asset_global_settle_operation op;
|
||||||
op.asset_to_settle = bit_usd_id;
|
op.asset_to_settle = bit_usd_id;
|
||||||
|
|
@ -476,6 +509,9 @@ BOOST_AUTO_TEST_CASE( unimp_global_settle_test )
|
||||||
PUSH_TX( db, trx );
|
PUSH_TX( db, trx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
force_settle(valentine_id(db), asset(990, bit_usd_id));
|
||||||
|
force_settle(dan_id(db), asset(495, bit_usd_id));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 0);
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, bit_usd_id), 0);
|
||||||
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 10046);
|
BOOST_CHECK_EQUAL(get_balance(valentine_id, asset_id_type()), 10046);
|
||||||
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 0);
|
||||||
|
|
@ -483,7 +519,6 @@ BOOST_AUTO_TEST_CASE( unimp_global_settle_test )
|
||||||
BOOST_CHECK_EQUAL(get_balance(dan_id, bit_usd_id), 0);
|
BOOST_CHECK_EQUAL(get_balance(dan_id, bit_usd_id), 0);
|
||||||
BOOST_CHECK_EQUAL(get_balance(dan_id, asset_id_type()), 9850);
|
BOOST_CHECK_EQUAL(get_balance(dan_id, asset_id_type()), 9850);
|
||||||
} FC_LOG_AND_RETHROW()
|
} FC_LOG_AND_RETHROW()
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( worker_create_test )
|
BOOST_AUTO_TEST_CASE( worker_create_test )
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue