31 #include <graphene/chain/hardfork.hpp> 40 namespace graphene {
namespace chain {
46 a.
num_auths() <= chain_params.maximum_authority_membership,
47 internal_verify_auth_max_auth_exceeded,
48 "Maximum authority membership exceeded" );
52 internal_verify_auth_account_not_found,
53 "Account ${a} specified in authority does not exist",
68 "Voted for more witnesses than currently allowed (${c})", (
"c", chain_params.maximum_witness_count) );
70 "Voted for more committee members than currently allowed (${c})", (
"c", chain_params.maximum_committee_count) );
74 uint32_t max_vote_id = gpo.next_available_vote_id;
75 bool has_worker_votes =
false;
76 for(
auto id : options.
votes )
78 FC_ASSERT(
id < max_vote_id,
"Can not vote for ${id} which does not exist.", (
"id",
id) );
80 has_worker_votes =
true;
86 for(
auto id : options.
votes )
90 FC_ASSERT( against_worker_idx.find(
id ) == against_worker_idx.end(),
91 "Can no longer vote against a worker." );
99 for (
auto id : options.
votes ) {
100 switch (
id.type() ) {
102 FC_ASSERT( committee_idx.find(
id) != committee_idx.end(),
103 "Can not vote for ${id} which does not exist.", (
"id",id) );
106 FC_ASSERT( witness_idx.find(
id) != witness_idx.end(),
107 "Can not vote for ${id} which does not exist.", (
"id",id) );
110 FC_ASSERT( approve_worker_idx.find(
id ) != approve_worker_idx.end(),
111 "Can not vote for ${id} which does not exist.", (
"id",id) );
114 FC_THROW(
"Invalid Vote Type: ${id}", (
"id",
id) );
133 GRAPHENE_RECODE_EXC( internal_verify_auth_max_auth_exceeded, account_create_max_auth_exceeded )
134 GRAPHENE_RECODE_EXC( internal_verify_auth_account_not_found, account_create_auth_account_not_found )
136 if( op.
extensions.value.owner_special_authority.valid() )
138 if( op.
extensions.value.active_special_authority.valid() )
140 if( op.
extensions.value.buyback_options.valid() )
147 auto current_account_itr = acnt_indx.
indices().get<by_name>().find( op.
name );
148 FC_ASSERT( current_account_itr == acnt_indx.indices().get<by_name>().end(),
149 "Account '${a}' already exists.", (
"a",op.
name) );
160 bool has_small_percent = (
167 if( has_small_percent )
169 if( referrer_percent >= 100 )
171 wlog(
"between 100% and 0x100%: ${o}", (
"o", o) );
173 referrer_percent = referrer_percent*100;
180 const auto& new_acnt_object = d.
create<
account_object>( [&o,&d,&global_properties,referrer_percent]
185 obj.lifetime_referrer = o.
referrer(d).lifetime_referrer;
187 const auto& params = global_properties.parameters;
189 obj.lifetime_referrer_fee_percentage = params.lifetime_referrer_percent_of_fee;
190 obj.referrer_rewards_percentage = referrer_percent;
200 s.is_voting = obj.options.is_voting();
207 if( o.extensions.value.buyback_options.valid() )
209 obj.allowed_assets = o.extensions.value.buyback_options->markets;
210 obj.
allowed_assets->emplace( o.extensions.value.buyback_options->asset_to_buy );
213 obj.creation_block_num = d._current_block_num;
217 const auto& dynamic_properties = d.get_dynamic_global_properties();
222 if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0
223 && global_properties.parameters.account_fee_scale_bitshifts != 0 )
235 sa.account = new_acnt_object.id;
239 if( o.extensions.value.buyback_options.valid() )
241 asset_id_type asset_to_buy = o.extensions.value.buyback_options->asset_to_buy;
245 bo.asset_to_buy = asset_to_buy;
254 return new_acnt_object.
id;
267 GRAPHENE_RECODE_EXC( internal_verify_auth_max_auth_exceeded, account_update_max_auth_exceeded )
268 GRAPHENE_RECODE_EXC( internal_verify_auth_account_not_found, account_update_auth_account_not_found )
270 if( o.
extensions.value.owner_special_authority.valid() )
272 if( o.
extensions.value.active_special_authority.valid() )
287 bool sa_before = acnt->has_special_authority();
292 if ( o.
new_options->voting_account != acnt->options.voting_account
308 a.top_n_control_flags = 0;
312 a.active = *o.active;
313 a.top_n_control_flags = 0;
317 a.options = *o.new_options;
318 a.num_committee_voted = a.options.num_committee_voted();
320 if( o.
extensions.value.owner_special_authority.valid() )
325 if( o.
extensions.value.active_special_authority.valid() )
332 bool sa_after = acnt->has_special_authority();
334 if( sa_before && (!sa_after) )
337 auto sa_it = sa_idx.find( o.
account );
338 assert( sa_it != sa_idx.end() );
341 else if( (!sa_before) && sa_after )
400 FC_ASSERT(!account->is_lifetime_member());
414 a.statistics(d).process_fees(a, d);
415 a.membership_expiration_date = time_point_sec::maximum();
416 a.referrer = a.registrar = a.lifetime_referrer = a.get_id();
417 a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - a.network_fee_percentage;
422 "May not extend annual membership more than a decade into the future.");
bool is_annual_member(time_point_sec now) const
void evaluate_buyback_account_options(const database &db, const buyback_account_options &bbo)
account_id_type registrar
This account pays the fee. Must be a lifetime member.
void modify(const T &obj, const Lambda &m)
extension< ext > extensions
chain_parameters parameters
time_point_sec membership_expiration_date
flat_set< account_id_type > blacklisting_accounts
bool upgrade_to_lifetime_member
If true, the account will be upgraded to a lifetime member; otherwise, it will add a year to the subs...
extension< ext > extensions
Identifies a weighted set of keys and accounts that must approve operations.
Manage an account's membership statusThis operation is used to upgrade an account to a member...
uint16_t referrer_percent
const index_type & indices() const
special_authority active_special_authority
time_point_sec head_block_time() const
This class represents an account on the object graphAccounts are the primary unit of authority on the...
Maintains global state information (committee_member list, current fees)This is an implementation det...
tracks the blockchain state in an extensible manner
const IndexType & get_index_type() const
Update an existing account.
void_result do_evaluate(const operation_type &o)
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
object_id_type do_apply(const account_create_operation &o)
optional< authority > active
New active authority. This can be updated by the current active authority.
uint16_t network_fee_percentage
Percentage of fee which should go to network.
const account_object * fee_paying_account
time_point_sec creation_time
The time when the account was created.
void_result do_evaluate(const account_whitelist_operation &o)
optional< authority > owner
New owner authority. If set, this operation requires owner authority to execute.
optional< account_id_type > buyback_account
optional< account_options > new_options
New account options.
uint8_t account_fee_scale_bitshifts
number of times to left bitshift account registration fee at each scaling
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
set< account_id_type > whitelisted_accounts
void_result do_apply(const account_update_operation &o)
uint16_t num_committee_voted() const
account_id_type voting_account
optional< flat_set< asset_id_type > > allowed_assets
account_id_type authorizing_account
The account which is specifying an opinion of another account.
microseconds days(int64_t d)
bool is_lifetime_member() const
This account is blacklisted, but not whitelisted.
object_id< SpaceID, TypeID > get_id() const
const T & get(const object_id_type &id) const
These are the fields which can be updated by the active authority.
const T * find(const object_id_type &id) const
flat_set< vote_id_type > votes
#define GRAPHENE_100_PERCENT
account_id_type referrer
This account receives a portion of the fee split between registrar and referrer. Must be a member...
void verify_authority_accounts(const database &db, const authority &a)
const object & get(object_id_type id) const
flat_map< account_id_type, weight_type > account_auths
#define FC_CAPTURE_AND_RETHROW(...)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
string name
The account's name. This name must be unique among all account names on the graph. May not be empty.
void_result do_apply(const account_whitelist_operation &o)
bool allow_non_member_whitelists
true if non-member accounts may set whitelists and blacklists; false otherwise
This account is whitelisted, but not blacklisted.
flat_set< account_id_type > whitelisting_accounts
set< account_id_type > blacklisted_accounts
uint32_t accounts_registered_this_interval
This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted ...
void verify_account_votes(const database &db, const account_options &options)
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
account_id_type account
The account to update.
void_result do_apply(const operation_type &o)
uint32_t num_auths() const
bool is_basic_account(time_point_sec now) const
account_statistics_id_type statistics
void evaluate_special_authority(const database &db, const special_authority &auth)
uint8_t top_n_control_flags
void remove(const object &obj)
Maintains global state information (committee_member list, current fees)This is an implementation det...
#define GRAPHENE_ASSERT(expr, exc_type, FORMAT,...)
account_id_type registrar
The account that paid the fee to register this account. Receives a percentage of referral rewards...
void_result do_evaluate(const account_create_operation &o)
#define GRAPHENE_RECODE_EXC(cause_type, effect_type)
fee_schedule & get_mutable_fees()
account_id_type referrer
The account credited as referring this account. Receives a percentage of referral rewards...
const T & create(F &&constructor)
const Operation::fee_parameters_type & get() const
account_id_type account_to_list
The account being opined about.
void_result do_evaluate(const account_update_operation &o)
special_authority owner_special_authority
const global_property_object & get_global_properties() const