Implemented item 1
This commit is contained in:
parent
10fa56a018
commit
fe7c8d6ad1
7 changed files with 61 additions and 2 deletions
|
|
@ -108,6 +108,8 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
|
||||||
FC_ASSERT( !op.extensions.value.active_special_authority.valid() );
|
FC_ASSERT( !op.extensions.value.active_special_authority.valid() );
|
||||||
FC_ASSERT( !op.extensions.value.buyback_options.valid() );
|
FC_ASSERT( !op.extensions.value.buyback_options.valid() );
|
||||||
}
|
}
|
||||||
|
if( d.head_block_time() < HARDFORK_999_TIME )
|
||||||
|
FC_ASSERT( !op.extensions.value.affiliate_distributions.valid(), "Affiliate reward distributions not allowed yet" );
|
||||||
|
|
||||||
FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." );
|
FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." );
|
||||||
FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." );
|
FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." );
|
||||||
|
|
@ -186,6 +188,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
|
||||||
obj.allowed_assets = o.extensions.value.buyback_options->markets;
|
obj.allowed_assets = o.extensions.value.buyback_options->markets;
|
||||||
obj.allowed_assets->emplace( o.extensions.value.buyback_options->asset_to_buy );
|
obj.allowed_assets->emplace( o.extensions.value.buyback_options->asset_to_buy );
|
||||||
}
|
}
|
||||||
|
obj.affiliate_distributions = o.extensions.value.affiliate_distributions;
|
||||||
});
|
});
|
||||||
|
|
||||||
if( has_small_percent )
|
if( has_small_percent )
|
||||||
|
|
|
||||||
4
libraries/chain/hardfork.d/999.hf
Normal file
4
libraries/chain/hardfork.d/999.hf
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Placeholder HF for affiliate reward system
|
||||||
|
#ifndef HARDFORK_999_TIME
|
||||||
|
#define HARDFORK_999_TIME (fc::time_point_sec( 1600000000 ))
|
||||||
|
#endif
|
||||||
|
|
@ -227,6 +227,8 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
optional< flat_set<asset_id_type> > allowed_assets;
|
optional< flat_set<asset_id_type> > allowed_assets;
|
||||||
|
|
||||||
|
optional< affiliate_reward_distributions > affiliate_distributions;
|
||||||
|
|
||||||
bool has_special_authority()const
|
bool has_special_authority()const
|
||||||
{
|
{
|
||||||
return (owner_special_authority.which() != special_authority::tag< no_special_authority >::value)
|
return (owner_special_authority.which() != special_authority::tag< no_special_authority >::value)
|
||||||
|
|
@ -446,7 +448,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_object,
|
||||||
(cashback_vb)
|
(cashback_vb)
|
||||||
(owner_special_authority)(active_special_authority)
|
(owner_special_authority)(active_special_authority)
|
||||||
(top_n_control_flags)
|
(top_n_control_flags)
|
||||||
(allowed_assets)
|
(allowed_assets)(affiliate_distributions)
|
||||||
)
|
)
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::account_balance_object,
|
FC_REFLECT_DERIVED( graphene::chain::account_balance_object,
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@
|
||||||
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
|
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
|
||||||
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
|
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
|
||||||
|
|
||||||
#define GRAPHENE_CURRENT_DB_VERSION "PPY1.11"
|
#define GRAPHENE_CURRENT_DB_VERSION "PPY_999"
|
||||||
|
|
||||||
#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
|
#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,21 @@ namespace graphene { namespace chain {
|
||||||
void validate()const;
|
void validate()const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum app_tag {
|
||||||
|
bookie = 0,
|
||||||
|
rps = 1
|
||||||
|
};
|
||||||
|
struct affiliate_reward_distribution
|
||||||
|
{
|
||||||
|
fc::flat_map<account_id_type,uint16_t> _dist;
|
||||||
|
void validate()const;
|
||||||
|
};
|
||||||
|
struct affiliate_reward_distributions
|
||||||
|
{
|
||||||
|
fc::flat_map<app_tag,affiliate_reward_distribution> _dists;
|
||||||
|
void validate()const;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup operations
|
* @ingroup operations
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,6 +86,7 @@ namespace graphene { namespace chain {
|
||||||
optional< special_authority > owner_special_authority;
|
optional< special_authority > owner_special_authority;
|
||||||
optional< special_authority > active_special_authority;
|
optional< special_authority > active_special_authority;
|
||||||
optional< buyback_account_options > buyback_options;
|
optional< buyback_account_options > buyback_options;
|
||||||
|
optional< affiliate_reward_distributions > affiliate_distributions;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fee_parameters_type
|
struct fee_parameters_type
|
||||||
|
|
@ -268,6 +284,10 @@ FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witn
|
||||||
FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing,
|
FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing,
|
||||||
(no_listing)(white_listed)(black_listed)(white_and_black_listed))
|
(no_listing)(white_listed)(black_listed)(white_and_black_listed))
|
||||||
|
|
||||||
|
FC_REFLECT_ENUM( graphene::chain::app_tag, (bookie)(rps) )
|
||||||
|
FC_REFLECT( graphene::chain::affiliate_reward_distribution, (_dist) );
|
||||||
|
FC_REFLECT( graphene::chain::affiliate_reward_distributions, (_dists) );
|
||||||
|
|
||||||
FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) )
|
FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) )
|
||||||
FC_REFLECT( graphene::chain::account_create_operation,
|
FC_REFLECT( graphene::chain::account_create_operation,
|
||||||
(fee)(registrar)
|
(fee)(registrar)
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@
|
||||||
#include <graphene/chain/proposal_evaluator.hpp>
|
#include <graphene/chain/proposal_evaluator.hpp>
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/account_object.hpp>
|
#include <graphene/chain/account_object.hpp>
|
||||||
|
#include <graphene/chain/protocol/account.hpp>
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
#include <graphene/chain/exceptions.hpp>
|
#include <graphene/chain/exceptions.hpp>
|
||||||
|
#include <graphene/chain/hardfork.hpp>
|
||||||
|
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
|
|
||||||
|
|
@ -120,6 +122,11 @@ struct proposal_operation_hardfork_visitor
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_update_status_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_update_status_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator()(const graphene::chain::account_create_operation &aco) const {
|
||||||
|
if (block_time < HARDFORK_999_TIME)
|
||||||
|
FC_ASSERT( !aco.extensions.value.affiliate_distributions.valid(), "Affiliate reward distributions not allowed yet" );
|
||||||
|
}
|
||||||
|
|
||||||
// loop and self visit in proposals
|
// loop and self visit in proposals
|
||||||
void operator()(const proposal_create_operation &v) const {
|
void operator()(const proposal_create_operation &v) const {
|
||||||
for (const op_wrapper &op : v.proposed_ops)
|
for (const op_wrapper &op : v.proposed_ops)
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,27 @@ void account_options::validate() const
|
||||||
"May not specify fewer witnesses or committee members than the number voted for.");
|
"May not specify fewer witnesses or committee members than the number voted for.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void affiliate_reward_distribution::validate() const
|
||||||
|
{
|
||||||
|
// sum of weights must equal 100%
|
||||||
|
uint32_t sum = 0;
|
||||||
|
for( const auto& share : _dist )
|
||||||
|
{
|
||||||
|
FC_ASSERT( share.second > 0, "Must leave out affilates who receive 0%!" );
|
||||||
|
FC_ASSERT( share.second <= GRAPHENE_100_PERCENT, "Can't pay out more than 100% per affiliate!" );
|
||||||
|
sum += share.second;
|
||||||
|
FC_ASSERT( sum <= GRAPHENE_100_PERCENT, "Can't pay out more than 100% total!" );
|
||||||
|
}
|
||||||
|
FC_ASSERT( sum == GRAPHENE_100_PERCENT, "Total affiliate distributions must cover 100%!" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void affiliate_reward_distributions::validate() const
|
||||||
|
{
|
||||||
|
FC_ASSERT( !_dists.empty(), "Empty affiliate reward distributions not allowed!" );
|
||||||
|
for( const auto& dist: _dists )
|
||||||
|
dist.second.validate();
|
||||||
|
}
|
||||||
|
|
||||||
share_type account_create_operation::calculate_fee( const fee_parameters_type& k )const
|
share_type account_create_operation::calculate_fee( const fee_parameters_type& k )const
|
||||||
{
|
{
|
||||||
auto core_fee_required = k.basic_fee;
|
auto core_fee_required = k.basic_fee;
|
||||||
|
|
@ -226,6 +247,8 @@ void account_create_operation::validate()const
|
||||||
FC_ASSERT( m != extensions.value.buyback_options->asset_to_buy );
|
FC_ASSERT( m != extensions.value.buyback_options->asset_to_buy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( extensions.value.affiliate_distributions.valid() )
|
||||||
|
extensions.value.affiliate_distributions->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue