parent
a2f7d704fe
commit
bba5681722
5 changed files with 48 additions and 12 deletions
|
|
@ -78,6 +78,16 @@ void account_statistics_object::process_fees(const account_object& a, database&
|
|||
|
||||
auto pay_out_fees = [&](const account_object& account, share_type core_fee_total, bool require_vesting)
|
||||
{
|
||||
// Check the referrer and registrar -- if they're no longer members, pay up to the lifetime member instead.
|
||||
if( account.referrer(d).is_basic_account(d.head_block_time()) )
|
||||
d.modify(account, [](account_object& a) {
|
||||
a.referrer = a.lifetime_referrer;
|
||||
});
|
||||
if( account.registrar(d).is_basic_account(d.head_block_time()) )
|
||||
d.modify(account, [](account_object& a) {
|
||||
a.registrar = a.lifetime_referrer;
|
||||
});
|
||||
|
||||
share_type network_cut = cut_fee(core_fee_total, account.network_fee_percentage);
|
||||
assert( network_cut <= core_fee_total );
|
||||
share_type burned = cut_fee(network_cut, props.parameters.burn_percent_of_fee);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,14 @@ vector<std::reference_wrapper<const ObjectType>> database::sort_votable_objects(
|
|||
return refs;
|
||||
}
|
||||
|
||||
template<class... Types>
|
||||
void database::perform_account_maintenance(std::tuple<Types...> helpers)
|
||||
{
|
||||
const auto& idx = get_index_type<account_index>().indices();
|
||||
for( const account_object& a : idx )
|
||||
detail::for_each(helpers, a, detail::gen_seq<sizeof...(Types)>());
|
||||
}
|
||||
|
||||
void database::pay_workers( share_type& budget )
|
||||
{
|
||||
// ilog("Processing payroll! Available budget is ${b}", ("b", budget));
|
||||
|
|
|
|||
|
|
@ -498,14 +498,6 @@ namespace graphene { namespace chain {
|
|||
(void)l;
|
||||
}
|
||||
}
|
||||
template<class... Types>
|
||||
void database::perform_account_maintenance(std::tuple<Types...> helpers)
|
||||
{
|
||||
const auto& idx = get_index_type<account_index>().indices();
|
||||
for( const account_object& a : idx )
|
||||
detail::for_each(helpers, a, detail::gen_seq<sizeof...(Types)>());
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
FC_REFLECT(graphene::chain::genesis_state_type::allocation_target_type, (name)(addr)(weight))
|
||||
|
|
|
|||
|
|
@ -628,9 +628,9 @@ void database_fixture::update_feed_producers( const asset_object& mia, flat_set<
|
|||
op.asset_to_update = mia.id;
|
||||
op.issuer = mia.issuer;
|
||||
op.new_feed_producers = std::move(producers);
|
||||
trx.operations.emplace_back( std::move(op) );
|
||||
trx.operations = {std::move(op)};
|
||||
|
||||
for( auto& op : trx.operations ) op.visit( operation_set_fee( db.current_fee_schedule() ) );
|
||||
trx.visit(operation_set_fee(db.current_fee_schedule()));
|
||||
trx.validate();
|
||||
db.push_transaction(trx, ~0);
|
||||
trx.operations.clear();
|
||||
|
|
|
|||
|
|
@ -95,13 +95,39 @@ BOOST_AUTO_TEST_CASE( cashback_test )
|
|||
CustomRegisterActor(pleb, reggie, stud, 95);
|
||||
CustomRegisterActor(scud, stud, ann, 80);
|
||||
|
||||
generate_block();
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time, true);
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
enable_fees(10000);
|
||||
|
||||
BOOST_CHECK_EQUAL(life_id(db).cashback_balance(db).balance.amount.value, 78000);
|
||||
BOOST_CHECK_EQUAL(reggie_id(db).cashback_balance(db).balance.amount.value, 34000);
|
||||
BOOST_CHECK_EQUAL(ann_id(db).cashback_balance(db).balance.amount.value, 40000);
|
||||
BOOST_CHECK_EQUAL(stud_id(db).cashback_balance(db).balance.amount.value, 8000);
|
||||
|
||||
transfer(stud_id, scud_id, asset(500000));
|
||||
transfer(scud_id, pleb_id, asset(400000));
|
||||
transfer(pleb_id, dumy_id, asset(300000));
|
||||
transfer(dumy_id, reggie_id, asset(200000));
|
||||
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
|
||||
BOOST_CHECK_EQUAL(life_id(db).cashback_balance(db).balance.amount.value, 87750);
|
||||
BOOST_CHECK_EQUAL(reggie_id(db).cashback_balance(db).balance.amount.value, 35500);
|
||||
BOOST_CHECK_EQUAL(ann_id(db).cashback_balance(db).balance.amount.value, 44000);
|
||||
BOOST_CHECK_EQUAL(stud_id(db).cashback_balance(db).balance.amount.value, 24750);
|
||||
|
||||
generate_blocks(ann_id(db).membership_expiration_date);
|
||||
generate_block();
|
||||
enable_fees(10000);
|
||||
|
||||
//ann's membership has expired, so scud's fee should go up to life instead.
|
||||
transfer(scud_id, pleb_id, asset(10));
|
||||
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
|
||||
BOOST_CHECK_EQUAL(life_id(db).cashback_balance(db).balance.amount.value, 94750);
|
||||
BOOST_CHECK_EQUAL(reggie_id(db).cashback_balance(db).balance.amount.value, 35500);
|
||||
BOOST_CHECK_EQUAL(ann_id(db).cashback_balance(db).balance.amount.value, 44000);
|
||||
BOOST_CHECK_EQUAL(stud_id(db).cashback_balance(db).balance.amount.value, 25750);
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
Loading…
Reference in a new issue