Implement GRAPHENE_PROXY_TO_SELF_ACCOUNT #267
This commit is contained in:
parent
143c1395c2
commit
19d10e462c
7 changed files with 22 additions and 6 deletions
|
|
@ -274,6 +274,16 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
a.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
|
||||
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
|
||||
}).get_id() == GRAPHENE_TEMP_ACCOUNT);
|
||||
FC_ASSERT(create<account_object>([this](account_object& a) {
|
||||
a.name = "proxy-to-self";
|
||||
a.statistics = create<account_statistics_object>([&](account_statistics_object& s){s.owner = a.id;}).id;
|
||||
a.owner.weight_threshold = 1;
|
||||
a.active.weight_threshold = 1;
|
||||
a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_NULL_ACCOUNT;
|
||||
a.membership_expiration_date = time_point_sec::maximum();
|
||||
a.network_fee_percentage = 0;
|
||||
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT;
|
||||
}).get_id() == GRAPHENE_PROXY_TO_SELF_ACCOUNT);
|
||||
|
||||
// Create more special accounts
|
||||
while( true )
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
|||
// specifying the opinions.
|
||||
const account_object& opinion_account =
|
||||
(stake_account.options.voting_account ==
|
||||
account_id_type())? stake_account
|
||||
GRAPHENE_PROXY_TO_SELF_ACCOUNT)? stake_account
|
||||
: d.get(stake_account.options.voting_account);
|
||||
|
||||
const auto& stats = stake_account.statistics(d);
|
||||
|
|
|
|||
|
|
@ -156,4 +156,6 @@
|
|||
#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3))
|
||||
/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account)
|
||||
#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4))
|
||||
/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy)
|
||||
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5))
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ namespace graphene { namespace chain {
|
|||
/// validated account activities. This field is here to prevent confusion if the active authority has zero or
|
||||
/// multiple keys in it.
|
||||
public_key_type memo_key;
|
||||
/// If this field is set to an account ID other than 0, this account's votes will be ignored and its stake
|
||||
/// If this field is set to an account ID other than GRAPHENE_PROXY_TO_SELF_ACCOUNT,
|
||||
/// then this account's votes will be ignored; its stake
|
||||
/// will be counted as voting for the referenced account's selected votes instead.
|
||||
account_id_type voting_account;
|
||||
account_id_type voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
|
||||
|
||||
/// The number of active witnesses this account votes the blockchain should appoint
|
||||
/// Must not exceed the actual number of witnesses voted for in @ref votes
|
||||
|
|
|
|||
|
|
@ -1418,9 +1418,9 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
if (account_object_to_modify.options.voting_account == account_id_type())
|
||||
if (account_object_to_modify.options.voting_account == GRAPHENE_PROXY_TO_SELF_ACCOUNT)
|
||||
FC_THROW("Account ${account} is already voting for itself", ("account", account_to_modify));
|
||||
account_object_to_modify.options.voting_account = account_id_type();
|
||||
account_object_to_modify.options.voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
|
||||
}
|
||||
|
||||
account_update_operation account_update_op;
|
||||
|
|
|
|||
|
|
@ -333,6 +333,7 @@ account_create_operation database_fixture::make_account(
|
|||
create_account.owner = authority(123, key, 123);
|
||||
create_account.active = authority(321, key, 321);
|
||||
create_account.options.memo_key = key;
|
||||
create_account.options.voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
|
||||
|
||||
auto& active_committee_members = db.get_global_properties().active_committee_members;
|
||||
if( active_committee_members.size() > 0 )
|
||||
|
|
@ -371,6 +372,7 @@ account_create_operation database_fixture::make_account(
|
|||
create_account.owner = authority(123, key, 123);
|
||||
create_account.active = authority(321, key, 321);
|
||||
create_account.options.memo_key = key;
|
||||
create_account.options.voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
|
||||
|
||||
const vector<committee_member_id_type>& active_committee_members = db.get_global_properties().active_committee_members;
|
||||
if( active_committee_members.size() > 0 )
|
||||
|
|
@ -555,6 +557,7 @@ const account_object& database_fixture::create_account(
|
|||
account_create_op.owner = authority(1234, public_key_type(key.get_public_key()), 1234);
|
||||
account_create_op.active = authority(5678, public_key_type(key.get_public_key()), 5678);
|
||||
account_create_op.options.memo_key = key.get_public_key();
|
||||
account_create_op.options.voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT;
|
||||
trx.operations.push_back( account_create_op );
|
||||
|
||||
trx.validate();
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE( create_account_test )
|
|||
BOOST_CHECK(nathan_account.owner.key_auths.at(committee_key) == 123);
|
||||
BOOST_REQUIRE(nathan_account.active.num_auths() == 1);
|
||||
BOOST_CHECK(nathan_account.active.key_auths.at(committee_key) == 321);
|
||||
BOOST_CHECK(nathan_account.options.voting_account == account_id_type());
|
||||
BOOST_CHECK(nathan_account.options.voting_account == GRAPHENE_PROXY_TO_SELF_ACCOUNT);
|
||||
BOOST_CHECK(nathan_account.options.memo_key == committee_key);
|
||||
|
||||
const account_statistics_object& statistics = nathan_account.statistics(db);
|
||||
|
|
|
|||
Loading…
Reference in a new issue