Merge branch 'master' of github.com:cryptonomex/graphene

This commit is contained in:
Daniel Larimer 2015-07-13 16:23:22 -04:00
commit 0beeac94aa
59 changed files with 656 additions and 629 deletions

View file

@ -231,8 +231,8 @@ Questions
- The answer to the previous question was really confusing. Can you make it clearer? - The answer to the previous question was really confusing. Can you make it clearer?
All account ID's are of the form `1.2.x`. If you were the 9735th account to be registered, All account ID's are of the form `1.2.x`. If you were the 9735th account to be registered,
your account's ID will be `1.2.9735`. Account `0` is special (it's the "genesis account," your account's ID will be `1.2.9735`. Account `0` is special (it's the "committee account,"
which is controlled by the delegates and has a few abilities and restrictions other accounts which is controlled by the committee members and has a few abilities and restrictions other accounts
do not). do not).
All asset ID's are of the form `1.3.x`. If you were the 29th asset to be registered, All asset ID's are of the form `1.3.x`. If you were the 29th asset to be registered,

2
docs

@ -1 +1 @@
Subproject commit f3012a7328227e90da6ded944c3c4bf2a4ab94a0 Subproject commit 97435c1a622e41e0a5fc1be72aaadea62e1b7adb

View file

@ -247,9 +247,9 @@ namespace graphene { namespace app {
return result; return result;
} }
fc::optional<delegate_object> database_api::get_delegate_by_account(account_id_type account) const fc::optional<committee_member_object> database_api::get_committee_member_by_account(account_id_type account) const
{ {
const auto& idx = _db.get_index_type<delegate_index>().indices().get<by_account>(); const auto& idx = _db.get_index_type<committee_member_index>().indices().get<by_account>();
auto itr = idx.find(account); auto itr = idx.find(account);
if( itr != idx.end() ) if( itr != idx.end() )
return *itr; return *itr;
@ -293,27 +293,27 @@ namespace graphene { namespace app {
return witnesses_by_account_name; return witnesses_by_account_name;
} }
map<string, delegate_id_type> database_api::lookup_delegate_accounts(const string& lower_bound_name, uint32_t limit)const map<string, committee_member_id_type> database_api::lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const
{ {
FC_ASSERT( limit <= 1000 ); FC_ASSERT( limit <= 1000 );
const auto& delegates_by_id = _db.get_index_type<delegate_index>().indices().get<by_id>(); const auto& committee_members_by_id = _db.get_index_type<committee_member_index>().indices().get<by_id>();
// we want to order delegates by account name, but that name is in the account object // we want to order committee_members by account name, but that name is in the account object
// so the delegate_index doesn't have a quick way to access it. // so the committee_member_index doesn't have a quick way to access it.
// get all the names and look them all up, sort them, then figure out what // get all the names and look them all up, sort them, then figure out what
// records to return. This could be optimized, but we expect the // records to return. This could be optimized, but we expect the
// number of delegates to be few and the frequency of calls to be rare // number of committee_members to be few and the frequency of calls to be rare
std::map<std::string, delegate_id_type> delegates_by_account_name; std::map<std::string, committee_member_id_type> committee_members_by_account_name;
for (const delegate_object& delegate : delegates_by_id) for (const committee_member_object& committee_member : committee_members_by_id)
if (auto account_iter = _db.find(delegate.delegate_account)) if (auto account_iter = _db.find(committee_member.committee_member_account))
if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name
delegates_by_account_name.insert(std::make_pair(account_iter->name, delegate.id)); committee_members_by_account_name.insert(std::make_pair(account_iter->name, committee_member.id));
auto end_iter = delegates_by_account_name.begin(); auto end_iter = committee_members_by_account_name.begin();
while (end_iter != delegates_by_account_name.end() && limit--) while (end_iter != committee_members_by_account_name.end() && limit--)
++end_iter; ++end_iter;
delegates_by_account_name.erase(end_iter, delegates_by_account_name.end()); committee_members_by_account_name.erase(end_iter, committee_members_by_account_name.end());
return delegates_by_account_name; return committee_members_by_account_name;
} }
vector<optional<witness_object>> database_api::get_witnesses(const vector<witness_id_type>& witness_ids)const vector<optional<witness_object>> database_api::get_witnesses(const vector<witness_id_type>& witness_ids)const
@ -328,11 +328,11 @@ namespace graphene { namespace app {
return result; return result;
} }
vector<optional<delegate_object>> database_api::get_delegates(const vector<delegate_id_type>& delegate_ids)const vector<optional<committee_member_object>> database_api::get_committee_members(const vector<committee_member_id_type>& committee_member_ids)const
{ {
vector<optional<delegate_object>> result; result.reserve(delegate_ids.size()); vector<optional<committee_member_object>> result; result.reserve(committee_member_ids.size());
std::transform(delegate_ids.begin(), delegate_ids.end(), std::back_inserter(result), std::transform(committee_member_ids.begin(), committee_member_ids.end(), std::back_inserter(result),
[this](delegate_id_type id) -> optional<delegate_object> { [this](committee_member_id_type id) -> optional<committee_member_object> {
if(auto o = _db.find(id)) if(auto o = _db.find(id))
return *o; return *o;
return {}; return {};

View file

@ -22,7 +22,7 @@
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/balance_object.hpp> #include <graphene/chain/balance_object.hpp>
@ -170,11 +170,11 @@ namespace graphene { namespace app {
vector<asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector<asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const;
/** /**
* @brief Get the delegate owned by a given account * @brief Get the committee_member owned by a given account
* @param account The ID of the account whose delegate should be retrieved * @param account The ID of the account whose committee_member should be retrieved
* @return The delegate object, or null if the account does not have a delegate * @return The committee_member object, or null if the account does not have a committee_member
*/ */
fc::optional<delegate_object> get_delegate_by_account(account_id_type account)const; fc::optional<committee_member_object> get_committee_member_by_account(account_id_type account)const;
/** /**
* @brief Get the witness owned by a given account * @brief Get the witness owned by a given account
* @param account The ID of the account whose witness should be retrieved * @param account The ID of the account whose witness should be retrieved
@ -196,12 +196,12 @@ namespace graphene { namespace app {
map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const; map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
/** /**
* @brief Get names and IDs for registered delegates * @brief Get names and IDs for registered committee_members
* @param lower_bound_name Lower bound of the first name to return * @param lower_bound_name Lower bound of the first name to return
* @param limit Maximum number of results to return -- must not exceed 1000 * @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of delegate names to corresponding IDs * @return Map of committee_member names to corresponding IDs
*/ */
map<string, delegate_id_type> lookup_delegate_accounts(const string& lower_bound_name, uint32_t limit)const; map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const;
/** /**
* @brief Get a list of witnesses by ID * @brief Get a list of witnesses by ID
@ -213,13 +213,13 @@ namespace graphene { namespace app {
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const; vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const;
/** /**
* @brief Get a list of delegates by ID * @brief Get a list of committee_members by ID
* @param delegate_ids IDs of the delegates to retrieve * @param committee_member_ids IDs of the committee_members to retrieve
* @return The delegates corresponding to the provided IDs * @return The committee_members corresponding to the provided IDs
* *
* This function has semantics identical to @ref get_objects * This function has semantics identical to @ref get_objects
*/ */
vector<optional<delegate_object>> get_delegates(const vector<delegate_id_type>& delegate_ids)const; vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type>& committee_member_ids)const;
/** /**
* @group Push Notification Methods * @group Push Notification Methods
@ -471,13 +471,13 @@ FC_API(graphene::app::database_api,
(get_call_orders) (get_call_orders)
(get_settle_orders) (get_settle_orders)
(list_assets) (list_assets)
(get_delegate_by_account) (get_committee_member_by_account)
(get_witnesses) (get_witnesses)
(get_delegates) (get_committee_members)
(get_witness_by_account) (get_witness_by_account)
(get_witness_count) (get_witness_count)
(lookup_witness_accounts) (lookup_witness_accounts)
(lookup_delegate_accounts) (lookup_committee_member_accounts)
(subscribe_to_objects) (subscribe_to_objects)
(unsubscribe_from_objects) (unsubscribe_from_objects)
(subscribe_to_market) (subscribe_to_market)

View file

@ -8,7 +8,7 @@ add_library( graphene_chain
protocol/assert.cpp protocol/assert.cpp
protocol/account.cpp protocol/account.cpp
protocol/transfer.cpp protocol/transfer.cpp
protocol/delegate.cpp protocol/committee_member.cpp
protocol/witness.cpp protocol/witness.cpp
protocol/market.cpp protocol/market.cpp
protocol/proposal.cpp protocol/proposal.cpp
@ -29,7 +29,7 @@ add_library( graphene_chain
account_evaluator.cpp account_evaluator.cpp
assert_evaluator.cpp assert_evaluator.cpp
witness_evaluator.cpp witness_evaluator.cpp
delegate_evaluator.cpp committee_member_evaluator.cpp
asset_evaluator.cpp asset_evaluator.cpp
transfer_evaluator.cpp transfer_evaluator.cpp
proposal_evaluator.cpp proposal_evaluator.cpp

View file

@ -325,7 +325,7 @@ void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_updat
const asset_object& a = o.asset_to_update(d); const asset_object& a = o.asset_to_update(d);
FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset."); FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset.");
FC_ASSERT(a.issuer != account_id_type(), "Cannot set feed producers on a genesis-issued asset."); FC_ASSERT(a.issuer != GRAPHENE_COMMITTEE_ACCOUNT, "Cannot set feed producers on a committee-issued asset.");
const asset_bitasset_data_object& b = a.bitasset_data(d); const asset_bitasset_data_object& b = a.bitasset_data(d);
bitasset_to_update = &b; bitasset_to_update = &b;
@ -450,7 +450,7 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
//Verify that the publisher is authoritative to publish a feed //Verify that the publisher is authoritative to publish a feed
if( base.issuer == account_id_type() ) if( base.issuer == account_id_type() )
{ {
//It's a delegate-fed asset. Verify that publisher is an active delegate or witness. //It's a committee_member-fed asset. Verify that publisher is an active committee_member or witness.
FC_ASSERT(d.get(GRAPHENE_COMMITTEE_ACCOUNT).active.account_auths.count(o.publisher) || FC_ASSERT(d.get(GRAPHENE_COMMITTEE_ACCOUNT).active.account_auths.count(o.publisher) ||
d.get_global_properties().witness_accounts.count(o.publisher)); d.get_global_properties().witness_accounts.count(o.publisher));
} else { } else {

View file

@ -15,8 +15,8 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <graphene/chain/delegate_evaluator.hpp> #include <graphene/chain/committee_member_evaluator.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
@ -24,21 +24,21 @@
namespace graphene { namespace chain { namespace graphene { namespace chain {
void_result delegate_create_evaluator::do_evaluate( const delegate_create_operation& op ) void_result committee_member_create_evaluator::do_evaluate( const committee_member_create_operation& op )
{ try { { try {
FC_ASSERT(db().get(op.delegate_account).is_lifetime_member()); FC_ASSERT(db().get(op.committee_member_account).is_lifetime_member());
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type delegate_create_evaluator::do_apply( const delegate_create_operation& op ) object_id_type committee_member_create_evaluator::do_apply( const committee_member_create_operation& op )
{ try { { 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);
}); });
const auto& new_del_object = db().create<delegate_object>( [&]( delegate_object& obj ){ const auto& new_del_object = db().create<committee_member_object>( [&]( committee_member_object& obj ){
obj.delegate_account = op.delegate_account; obj.committee_member_account = op.committee_member_account;
obj.vote_id = vote_id; obj.vote_id = vote_id;
obj.url = op.url; obj.url = op.url;
}); });
@ -47,14 +47,14 @@ object_id_type delegate_create_evaluator::do_apply( const delegate_create_operat
void_result delegate_update_global_parameters_evaluator::do_evaluate(const delegate_update_global_parameters_operation& o) void_result committee_member_update_global_parameters_evaluator::do_evaluate(const committee_member_update_global_parameters_operation& o)
{ try { { 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) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result delegate_update_global_parameters_evaluator::do_apply(const delegate_update_global_parameters_operation& o) void_result committee_member_update_global_parameters_evaluator::do_apply(const committee_member_update_global_parameters_operation& o)
{ try { { 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;

View file

@ -271,7 +271,7 @@ signed_block database::_generate_block(
const auto& witness_obj = witness_id(*this); const auto& witness_obj = witness_id(*this);
if( !(skip & skip_delegate_signature) ) if( !(skip & skip_witness_signature) )
FC_ASSERT( witness_obj.signing_key == block_signing_private_key.get_public_key() ); FC_ASSERT( witness_obj.signing_key == block_signing_private_key.get_public_key() );
_pending_block.timestamp = when; _pending_block.timestamp = when;
@ -297,7 +297,7 @@ signed_block database::_generate_block(
_pending_block.transaction_merkle_root = _pending_block.calculate_merkle_root(); _pending_block.transaction_merkle_root = _pending_block.calculate_merkle_root();
_pending_block.witness = witness_id; _pending_block.witness = witness_id;
if( !(skip & skip_delegate_signature) ) _pending_block.sign( block_signing_private_key ); if( !(skip & skip_witness_signature) ) _pending_block.sign( block_signing_private_key );
FC_ASSERT( fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size ); FC_ASSERT( fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size );
signed_block tmp = _pending_block; signed_block tmp = _pending_block;
@ -645,7 +645,7 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
const witness_object& witness = next_block.witness(*this); const witness_object& witness = next_block.witness(*this);
FC_ASSERT( secret_hash_type::hash( next_block.previous_secret ) == witness.next_secret_hash, "", FC_ASSERT( secret_hash_type::hash( next_block.previous_secret ) == witness.next_secret_hash, "",
("previous_secret", next_block.previous_secret)("next_secret_hash", witness.next_secret_hash)); ("previous_secret", next_block.previous_secret)("next_secret_hash", witness.next_secret_hash));
if( !(skip&skip_delegate_signature) ) FC_ASSERT( next_block.validate_signee( witness.signing_key ) ); if( !(skip&skip_witness_signature) ) FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
uint32_t slot_num = get_slot_at_time( next_block.timestamp ); uint32_t slot_num = get_slot_at_time( next_block.timestamp );
FC_ASSERT( slot_num > 0 ); FC_ASSERT( slot_num > 0 );

View file

@ -21,7 +21,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/block_summary_object.hpp> #include <graphene/chain/block_summary_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/global_property_object.hpp> #include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/balance_object.hpp> #include <graphene/chain/balance_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
@ -35,7 +35,7 @@
#include <graphene/chain/asset_evaluator.hpp> #include <graphene/chain/asset_evaluator.hpp>
#include <graphene/chain/assert_evaluator.hpp> #include <graphene/chain/assert_evaluator.hpp>
#include <graphene/chain/custom_evaluator.hpp> #include <graphene/chain/custom_evaluator.hpp>
#include <graphene/chain/delegate_evaluator.hpp> #include <graphene/chain/committee_member_evaluator.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/proposal_evaluator.hpp> #include <graphene/chain/proposal_evaluator.hpp>
#include <graphene/chain/transfer_evaluator.hpp> #include <graphene/chain/transfer_evaluator.hpp>
@ -75,8 +75,8 @@ const uint8_t block_summary_object::type_id;
const uint8_t call_order_object::space_id; const uint8_t call_order_object::space_id;
const uint8_t call_order_object::type_id; const uint8_t call_order_object::type_id;
const uint8_t delegate_object::space_id; const uint8_t committee_member_object::space_id;
const uint8_t delegate_object::type_id; const uint8_t committee_member_object::type_id;
const uint8_t force_settlement_object::space_id; const uint8_t force_settlement_object::space_id;
const uint8_t force_settlement_object::type_id; const uint8_t force_settlement_object::type_id;
@ -119,8 +119,8 @@ void database::initialize_evaluators()
register_evaluator<account_update_evaluator>(); register_evaluator<account_update_evaluator>();
register_evaluator<account_upgrade_evaluator>(); register_evaluator<account_upgrade_evaluator>();
register_evaluator<account_whitelist_evaluator>(); register_evaluator<account_whitelist_evaluator>();
register_evaluator<delegate_create_evaluator>(); register_evaluator<committee_member_create_evaluator>();
register_evaluator<delegate_update_global_parameters_evaluator>(); register_evaluator<committee_member_update_global_parameters_evaluator>();
register_evaluator<custom_evaluator>(); register_evaluator<custom_evaluator>();
register_evaluator<asset_create_evaluator>(); register_evaluator<asset_create_evaluator>();
register_evaluator<asset_issue_evaluator>(); register_evaluator<asset_issue_evaluator>();
@ -165,7 +165,7 @@ void database::initialize_indexes()
acnt_index->add_secondary_index<account_member_index>(); acnt_index->add_secondary_index<account_member_index>();
acnt_index->add_secondary_index<account_referrer_index>(); acnt_index->add_secondary_index<account_referrer_index>();
add_index< primary_index<delegate_index> >(); add_index< primary_index<committee_member_index> >();
add_index< primary_index<witness_index> >(); add_index< primary_index<witness_index> >();
add_index< primary_index<limit_order_index > >(); add_index< primary_index<limit_order_index > >();
add_index< primary_index<call_order_index > >(); add_index< primary_index<call_order_index > >();
@ -476,8 +476,8 @@ void database::init_genesis(const genesis_state_type& genesis_state)
// Create initial committee members // Create initial committee members
std::for_each(genesis_state.initial_committee_candidates.begin(), genesis_state.initial_committee_candidates.end(), std::for_each(genesis_state.initial_committee_candidates.begin(), genesis_state.initial_committee_candidates.end(),
[&](const genesis_state_type::initial_committee_member_type& member) { [&](const genesis_state_type::initial_committee_member_type& member) {
delegate_create_operation op; committee_member_create_operation op;
op.delegate_account = get_account_id(member.owner_name); op.committee_member_account = get_account_id(member.owner_name);
apply_operation(genesis_eval_state, op); apply_operation(genesis_eval_state, op);
}); });

View file

@ -20,7 +20,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/global_property_object.hpp> #include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
@ -191,21 +191,21 @@ void database::update_active_witnesses()
}); });
} FC_CAPTURE_AND_RETHROW() } } FC_CAPTURE_AND_RETHROW() }
void database::update_active_delegates() void database::update_active_committee_members()
{ try { { try {
assert( _committee_count_histogram_buffer.size() > 0 ); assert( _committee_count_histogram_buffer.size() > 0 );
uint64_t stake_target = _total_voting_stake / 2; uint64_t stake_target = _total_voting_stake / 2;
uint64_t stake_tally = _committee_count_histogram_buffer[0]; uint64_t stake_tally = _committee_count_histogram_buffer[0];
size_t delegate_count = 0; size_t committee_member_count = 0;
if( stake_target > 0 ) if( stake_target > 0 )
while( (delegate_count < _committee_count_histogram_buffer.size() - 1) while( (committee_member_count < _committee_count_histogram_buffer.size() - 1)
&& (stake_tally <= stake_target) ) && (stake_tally <= stake_target) )
stake_tally += _committee_count_histogram_buffer[++delegate_count]; stake_tally += _committee_count_histogram_buffer[++committee_member_count];
auto delegates = sort_votable_objects<delegate_index>(std::max(delegate_count*2+1, (size_t)GRAPHENE_MIN_DELEGATE_COUNT)); auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT));
// Update genesis authorities // Update committee authorities
if( !delegates.empty() ) if( !committee_members.empty() )
{ {
modify(get(GRAPHENE_COMMITTEE_ACCOUNT), [&](account_object& a) { modify(get(GRAPHENE_COMMITTEE_ACCOUNT), [&](account_object& a) {
uint64_t total_votes = 0; uint64_t total_votes = 0;
@ -213,9 +213,9 @@ void database::update_active_delegates()
a.active.weight_threshold = 0; a.active.weight_threshold = 0;
a.active.clear(); a.active.clear();
for( const delegate_object& del : delegates ) for( const committee_member_object& del : committee_members )
{ {
weights.emplace(del.delegate_account, _vote_tally_buffer[del.vote_id]); weights.emplace(del.committee_member_account, _vote_tally_buffer[del.vote_id]);
total_votes += _vote_tally_buffer[del.vote_id]; total_votes += _vote_tally_buffer[del.vote_id];
} }
@ -238,10 +238,10 @@ void database::update_active_delegates()
}); });
} }
modify(get_global_properties(), [&](global_property_object& gp) { modify(get_global_properties(), [&](global_property_object& gp) {
gp.active_delegates.clear(); gp.active_committee_members.clear();
std::transform(delegates.begin(), delegates.end(), std::transform(committee_members.begin(), committee_members.end(),
std::inserter(gp.active_delegates, gp.active_delegates.begin()), std::inserter(gp.active_committee_members, gp.active_committee_members.begin()),
[](const delegate_object& d) { return d.id; }); [](const committee_member_object& d) { return d.id; });
}); });
} FC_CAPTURE_AND_RETHROW() } } FC_CAPTURE_AND_RETHROW() }
@ -457,7 +457,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
c(_vote_tally_buffer); c(_vote_tally_buffer);
update_active_witnesses(); update_active_witnesses();
update_active_delegates(); update_active_committee_members();
modify(gpo, [this](global_property_object& p) { modify(gpo, [this](global_property_object& p) {
// Remove scaling of account registration fee // Remove scaling of account registration fee

View file

@ -51,7 +51,7 @@ void database::reindex(fc::path data_dir, const genesis_state_type& initial_allo
//_undo_db.disable(); //_undo_db.disable();
for( uint32_t i = 1; i <= last_block_num; ++i ) for( uint32_t i = 1; i <= last_block_num; ++i )
{ {
apply_block(*_block_id_to_block.fetch_by_number(i), skip_delegate_signature | apply_block(*_block_id_to_block.fetch_by_number(i), skip_witness_signature |
skip_transaction_signatures | skip_transaction_signatures |
skip_undo_block | skip_undo_block |
skip_undo_transaction | skip_undo_transaction |

View file

@ -22,7 +22,7 @@
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>

View file

@ -108,7 +108,7 @@ namespace graphene { namespace chain {
* @ingroup protocol * @ingroup protocol
* *
* Accounts are the primary unit of authority on the graphene system. Users must have an account in order to use * Accounts are the primary unit of authority on the graphene system. Users must have an account in order to use
* assets, trade in the markets, vote for delegates, etc. * assets, trade in the markets, vote for committee_members, etc.
*/ */
class account_object : public graphene::db::annotated_object<account_object> class account_object : public graphene::db::annotated_object<account_object>
{ {
@ -231,7 +231,7 @@ namespace graphene { namespace chain {
static const uint8_t type_id = meta_account_object_type; static const uint8_t type_id = meta_account_object_type;
public_key_type memo_key; public_key_type memo_key;
delegate_id_type delegate_id; // optional committee_member_id_type committee_member_id; // optional
}; };
/** /**
@ -334,7 +334,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_balance_object,
FC_REFLECT_DERIVED( graphene::chain::meta_account_object, FC_REFLECT_DERIVED( graphene::chain::meta_account_object,
(graphene::db::object), (graphene::db::object),
(memo_key)(delegate_id) ) (memo_key)(committee_member_id) )
FC_REFLECT_DERIVED( graphene::chain::account_statistics_object, (graphene::chain::object), FC_REFLECT_DERIVED( graphene::chain::account_statistics_object, (graphene::chain::object),
(most_recent_op) (most_recent_op)

View file

@ -167,8 +167,8 @@ namespace graphene { namespace chain {
/// The tunable options for BitAssets are stored in this field. /// The tunable options for BitAssets are stored in this field.
bitasset_options options; bitasset_options options;
/// Feeds published for this asset. If issuer is not genesis, the keys in this map are the feed publishing /// Feeds published for this asset. If issuer is not committee, the keys in this map are the feed publishing
/// accounts; otherwise, the feed publishers are the currently active delegates and witnesses and this map /// accounts; otherwise, the feed publishers are the currently active committee_members and witnesses and this map
/// should be treated as an implementation detail. The timestamp on each feed is the time it was published. /// should be treated as an implementation detail. The timestamp on each feed is the time it was published.
flat_map<account_id_type, pair<time_point_sec,price_feed>> feeds; flat_map<account_id_type, pair<time_point_sec,price_feed>> feeds;
/// This is the currently active price feed, calculated as the median of values from the currently active /// This is the currently active price feed, calculated as the median of values from the currently active

View file

@ -17,26 +17,26 @@
*/ */
#pragma once #pragma once
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class delegate_create_evaluator : public evaluator<delegate_create_evaluator> class committee_member_create_evaluator : public evaluator<committee_member_create_evaluator>
{ {
public: public:
typedef delegate_create_operation operation_type; typedef committee_member_create_operation operation_type;
void_result do_evaluate( const delegate_create_operation& o ); void_result do_evaluate( const committee_member_create_operation& o );
object_id_type do_apply( const delegate_create_operation& o ); object_id_type do_apply( const committee_member_create_operation& o );
}; };
class delegate_update_global_parameters_evaluator : public evaluator<delegate_update_global_parameters_evaluator> class committee_member_update_global_parameters_evaluator : public evaluator<committee_member_update_global_parameters_evaluator>
{ {
public: public:
typedef delegate_update_global_parameters_operation operation_type; typedef committee_member_update_global_parameters_operation operation_type;
void_result do_evaluate( const delegate_update_global_parameters_operation& o ); void_result do_evaluate( const committee_member_update_global_parameters_operation& o );
void_result do_apply( const delegate_update_global_parameters_operation& o ); void_result do_apply( const committee_member_update_global_parameters_operation& o );
}; };

View file

@ -26,41 +26,41 @@ namespace graphene { namespace chain {
class account_object; class account_object;
/** /**
* @brief tracks information about a delegate account. * @brief tracks information about a committee_member account.
* @ingroup object * @ingroup object
* *
* A delegate is responsible for setting blockchain parameters and has * A committee_member is responsible for setting blockchain parameters and has
* dynamic multi-sig control over the genesis account. The current set of * dynamic multi-sig control over the committee account. The current set of
* active delegates has control. * active committee_members has control.
* *
* Delegates were separated into a separate object to make iterating over * committee_members were separated into a separate object to make iterating over
* the set of delegate easy. * the set of committee_member easy.
*/ */
class delegate_object : public abstract_object<delegate_object> class committee_member_object : public abstract_object<committee_member_object>
{ {
public: public:
static const uint8_t space_id = protocol_ids; static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = delegate_object_type; static const uint8_t type_id = committee_member_object_type;
account_id_type delegate_account; account_id_type committee_member_account;
vote_id_type vote_id; vote_id_type vote_id;
string url; string url;
}; };
struct by_account; struct by_account;
using delegate_multi_index_type = multi_index_container< using committee_member_multi_index_type = multi_index_container<
delegate_object, committee_member_object,
indexed_by< indexed_by<
ordered_unique< tag<by_id>, ordered_unique< tag<by_id>,
member<object, object_id_type, &object::id> member<object, object_id_type, &object::id>
>, >,
hashed_unique< tag<by_account>, hashed_unique< tag<by_account>,
member<delegate_object, account_id_type, &delegate_object::delegate_account> member<committee_member_object, account_id_type, &committee_member_object::committee_member_account>
> >
> >
>; >;
using delegate_index = generic_index<delegate_object, delegate_multi_index_type>; using committee_member_index = generic_index<committee_member_object, committee_member_multi_index_type>;
} } // graphene::chain } } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::delegate_object, (graphene::db::object), FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object),
(delegate_account)(vote_id)(url) ) (committee_member_account)(vote_id)(url) )

View file

@ -32,9 +32,9 @@
#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */ #define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */
#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 #define GRAPHENE_MAX_SIG_CHECK_DEPTH 2
#define GRAPHENE_MIN_WITNESS_COUNT 10 #define GRAPHENE_MIN_WITNESS_COUNT 10
#define GRAPHENE_MIN_DELEGATE_COUNT 10 #define GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT 10
/** /**
* Don't allow the delegates to publish a limit that would * Don't allow the committee_members to publish a limit that would
* make the network unable to operate. * make the network unable to operate.
*/ */
#define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024 #define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024

View file

@ -79,18 +79,18 @@ namespace graphene { namespace chain {
enum validation_steps enum validation_steps
{ {
skip_nothing = 0x00, skip_nothing = 0,
skip_delegate_signature = 0x01, ///< used while reindexing skip_witness_signature = 1 << 0, ///< used while reindexing
skip_transaction_signatures = 0x02, ///< used by non-witness nodes skip_transaction_signatures = 1 << 1, ///< used by non-witness nodes
skip_undo_block = 0x04, ///< used while reindexing skip_undo_block = 1 << 2, ///< used while reindexing
skip_undo_transaction = 0x08, ///< used while applying block skip_undo_transaction = 1 << 3, ///< used while applying block
skip_transaction_dupe_check = 0x10, ///< used while reindexing skip_transaction_dupe_check = 1 << 4, ///< used while reindexing
skip_fork_db = 0x20, ///< used while reindexing skip_fork_db = 1 << 5, ///< used while reindexing
skip_block_size_check = 0x40, ///< used when applying locally generated transactions skip_block_size_check = 1 << 6, ///< used when applying locally generated transactions
skip_tapos_check = 0x80, ///< used while reindexing -- note this skips expiration check as well skip_tapos_check = 1 << 7, ///< used while reindexing -- note this skips expiration check as well
skip_authority_check = 0x100, ///< used while reindexing -- disables any checking of authority on transactions skip_authority_check = 1 << 8, ///< used while reindexing -- disables any checking of authority on transactions
skip_merkle_check = 0x200, ///< used while reindexing skip_merkle_check = 1 << 9, ///< used while reindexing
skip_assert_evaluation = 0x400 ///< used while reindexing skip_assert_evaluation = 1 << 10 ///< used while reindexing
}; };
/** /**
@ -441,7 +441,7 @@ namespace graphene { namespace chain {
void pay_workers( share_type& budget ); void pay_workers( share_type& budget );
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props); void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
void update_active_witnesses(); void update_active_witnesses();
void update_active_delegates(); void update_active_committee_members();
template<class... Types> template<class... Types>
void perform_account_maintenance(std::tuple<Types...> helpers); void perform_account_maintenance(std::tuple<Types...> helpers);

View file

@ -100,7 +100,7 @@ namespace graphene { namespace chain {
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_settle ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_settle );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_global_settle ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_global_settle );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_publish_feed ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_publish_feed );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( delegate_create ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( committee_member_create );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_create ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_create );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_withdraw_pay ); //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( witness_withdraw_pay );
@ -154,7 +154,7 @@ namespace graphene { namespace chain {
FC_DECLARE_DERIVED_EXCEPTION( time_in_past, graphene::chain::chain_exception, 30018, "time is in the past" ) FC_DECLARE_DERIVED_EXCEPTION( time_in_past, graphene::chain::chain_exception, 30018, "time is in the past" )
FC_DECLARE_DERIVED_EXCEPTION( time_in_future, graphene::chain::chain_exception, 30019, "time is in the future" ) FC_DECLARE_DERIVED_EXCEPTION( time_in_future, graphene::chain::chain_exception, 30019, "time is in the future" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, graphene::chain::chain_exception, 30020, "invalid block digest" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, graphene::chain::chain_exception, 30020, "invalid block digest" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_delegate_signee, graphene::chain::chain_exception, 30021, "invalid delegate signee" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_member_signee, graphene::chain::chain_exception, 30021, "invalid committee_member signee" )
FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, graphene::chain::chain_exception, 30022, "failed checkpoint verification" ) FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, graphene::chain::chain_exception, 30022, "failed checkpoint verification" )
FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, graphene::chain::chain_exception, 30023, "wrong chain id" ) FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, graphene::chain::chain_exception, 30023, "wrong chain id" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_block, graphene::chain::chain_exception, 30024, "unknown block" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_block, graphene::chain::chain_exception, 30024, "unknown block" )
@ -162,14 +162,14 @@ namespace graphene { namespace chain {
FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ) FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" )
FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, graphene::chain::evaluation_error, 31001, "negative deposit" ) FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, graphene::chain::evaluation_error, 31001, "negative deposit" )
FC_DECLARE_DERIVED_EXCEPTION( not_a_delegate, graphene::chain::evaluation_error, 31002, "not a delegate" ) FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member, graphene::chain::evaluation_error, 31002, "not a committee_member" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, graphene::chain::evaluation_error, 31003, "unknown balance record" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, graphene::chain::evaluation_error, 31003, "unknown balance record" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, graphene::chain::evaluation_error, 31004, "insufficient funds" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, graphene::chain::evaluation_error, 31004, "insufficient funds" )
FC_DECLARE_DERIVED_EXCEPTION( missing_signature, graphene::chain::evaluation_error, 31005, "missing signature" ) FC_DECLARE_DERIVED_EXCEPTION( missing_signature, graphene::chain::evaluation_error, 31005, "missing signature" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, graphene::chain::evaluation_error, 31006, "invalid claim password" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, graphene::chain::evaluation_error, 31006, "invalid claim password" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, graphene::chain::evaluation_error, 31007, "invalid withdraw condition" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, graphene::chain::evaluation_error, 31007, "invalid withdraw condition" )
FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, graphene::chain::evaluation_error, 31008, "negative withdraw" ) FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, graphene::chain::evaluation_error, 31008, "negative withdraw" )
FC_DECLARE_DERIVED_EXCEPTION( not_an_active_delegate, graphene::chain::evaluation_error, 31009, "not an active delegate" ) FC_DECLARE_DERIVED_EXCEPTION( not_an_active_committee_member, graphene::chain::evaluation_error, 31009, "not an active committee_member" )
FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, graphene::chain::evaluation_error, 31010, "expired transaction" ) FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, graphene::chain::evaluation_error, 31010, "expired transaction" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, graphene::chain::evaluation_error, 31011, "invalid transaction expiration" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, graphene::chain::evaluation_error, 31011, "invalid transaction expiration" )
FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, graphene::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" ) FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, graphene::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" )
@ -184,11 +184,11 @@ namespace graphene { namespace chain {
FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, graphene::chain::evaluation_error, 32008, "account key already in use" ) FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, graphene::chain::evaluation_error, 32008, "account key already in use" )
FC_DECLARE_DERIVED_EXCEPTION( account_retracted, graphene::chain::evaluation_error, 32009, "account retracted" ) FC_DECLARE_DERIVED_EXCEPTION( account_retracted, graphene::chain::evaluation_error, 32009, "account retracted" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, graphene::chain::evaluation_error, 32010, "unknown parent account name" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, graphene::chain::evaluation_error, 32010, "unknown parent account name" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_delegate_slate, graphene::chain::evaluation_error, 32011, "unknown delegate slate" ) FC_DECLARE_DERIVED_EXCEPTION( unknown_committee_member_slate, graphene::chain::evaluation_error, 32011, "unknown committee_member slate" )
FC_DECLARE_DERIVED_EXCEPTION( too_may_delegates_in_slate, graphene::chain::evaluation_error, 32012, "too many delegates in slate" ) FC_DECLARE_DERIVED_EXCEPTION( too_may_committee_members_in_slate, graphene::chain::evaluation_error, 32012, "too many committee_members in slate" )
FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, graphene::chain::evaluation_error, 32013, "pay balance remaining" ) FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, graphene::chain::evaluation_error, 32013, "pay balance remaining" )
FC_DECLARE_DERIVED_EXCEPTION( not_a_delegate_signature, graphene::chain::evaluation_error, 33002, "not delegates signature" ) FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member_signature, graphene::chain::evaluation_error, 33002, "not committee_members signature" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, graphene::chain::evaluation_error, 35001, "invalid precision" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, graphene::chain::evaluation_error, 35001, "invalid precision" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, graphene::chain::evaluation_error, 35002, "invalid asset symbol" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, graphene::chain::evaluation_error, 35002, "invalid asset symbol" )
@ -202,7 +202,7 @@ namespace graphene { namespace chain {
FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, graphene::chain::evaluation_error, 35010, "not user issued" ) FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, graphene::chain::evaluation_error, 35010, "not user issued" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, graphene::chain::evaluation_error, 35011, "invalid asset name" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, graphene::chain::evaluation_error, 35011, "invalid asset name" )
FC_DECLARE_DERIVED_EXCEPTION( delegate_vote_limit, graphene::chain::evaluation_error, 36001, "delegate_vote_limit" ) FC_DECLARE_DERIVED_EXCEPTION( committee_member_vote_limit, graphene::chain::evaluation_error, 36001, "committee_member_vote_limit" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::evaluation_error, 36002, "insufficient fee" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::evaluation_error, 36002, "insufficient fee" )
FC_DECLARE_DERIVED_EXCEPTION( negative_fee, graphene::chain::evaluation_error, 36003, "negative fee" ) FC_DECLARE_DERIVED_EXCEPTION( negative_fee, graphene::chain::evaluation_error, 36003, "negative fee" )
FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, graphene::chain::evaluation_error, 36004, "missing deposit" ) FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, graphene::chain::evaluation_error, 36004, "missing deposit" )

View file

@ -24,11 +24,11 @@ namespace graphene { namespace chain {
/** /**
* @class global_property_object * @class global_property_object
* @brief Maintains global state information (delegate list, current fees) * @brief Maintains global state information (committee_member list, current fees)
* @ingroup object * @ingroup object
* @ingroup implementation * @ingroup implementation
* *
* This is an implementation detail. The values here are set by delegates to tune the blockchain parameters. * This is an implementation detail. The values here are set by committee_members to tune the blockchain parameters.
*/ */
class global_property_object : public graphene::db::abstract_object<global_property_object> class global_property_object : public graphene::db::abstract_object<global_property_object>
{ {
@ -40,7 +40,7 @@ namespace graphene { namespace chain {
optional<chain_parameters> pending_parameters; optional<chain_parameters> pending_parameters;
uint32_t next_available_vote_id = 0; uint32_t next_available_vote_id = 0;
vector<delegate_id_type> active_delegates; // updated once per maintenance interval vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
// n.b. witness scheduling is done by witness_schedule object // n.b. witness scheduling is done by witness_schedule object
flat_set<account_id_type> witness_accounts; // updated once per maintenance interval flat_set<account_id_type> witness_accounts; // updated once per maintenance interval
@ -54,7 +54,7 @@ namespace graphene { namespace chain {
/** /**
* @class dynamic_global_property_object * @class dynamic_global_property_object
* @brief Maintains global state information (delegate list, current fees) * @brief Maintains global state information (committee_member list, current fees)
* @ingroup object * @ingroup object
* @ingroup implementation * @ingroup implementation
* *
@ -102,7 +102,7 @@ FC_REFLECT_DERIVED( graphene::chain::global_property_object, (graphene::db::obje
(parameters) (parameters)
(pending_parameters) (pending_parameters)
(next_available_vote_id) (next_available_vote_id)
(active_delegates) (active_committee_members)
(active_witnesses) (active_witnesses)
(chain_id) (chain_id)
) )

View file

@ -282,7 +282,7 @@ namespace graphene { namespace chain {
* This operation is used to specify which accounts may produce feeds for a given BitAsset. * This operation is used to specify which accounts may produce feeds for a given BitAsset.
* *
* @pre @ref issuer MUST be an existing account, and MUST match asset_object::issuer on @ref asset_to_update * @pre @ref issuer MUST be an existing account, and MUST match asset_object::issuer on @ref asset_to_update
* @pre @ref issuer MUST NOT be the genesis account * @pre @ref issuer MUST NOT be the committee account
* @pre @ref asset_to_update MUST be a BitAsset, i.e. @ref asset_object::is_market_issued() returns true * @pre @ref asset_to_update MUST be a BitAsset, i.e. @ref asset_object::is_market_issued() returns true
* @pre @ref fee MUST be nonnegative, and @ref issuer MUST have a sufficient balance to pay it * @pre @ref fee MUST be nonnegative, and @ref issuer MUST have a sufficient balance to pay it
* @pre Cardinality of @ref new_feed_producers MUST NOT exceed @ref chain_parameters::maximum_asset_feed_publishers * @pre Cardinality of @ref new_feed_producers MUST NOT exceed @ref chain_parameters::maximum_asset_feed_publishers
@ -311,7 +311,7 @@ namespace graphene { namespace chain {
* *
* Price feed providers use this operation to publish their price feeds for market-issued assets. A price feed is * Price feed providers use this operation to publish their price feeds for market-issued assets. A price feed is
* used to tune the market for a particular market-issued asset. For each value in the feed, the median across all * used to tune the market for a particular market-issued asset. For each value in the feed, the median across all
* delegate feeds for that asset is calculated and the market for the asset is configured with the median of that * committee_member feeds for that asset is calculated and the market for the asset is configured with the median of that
* value. * value.
* *
* The feed in the operation contains three prices: a call price limit, a short price limit, and a settlement price. * The feed in the operation contains three prices: a call price limit, a short price limit, and a settlement price.

View file

@ -36,7 +36,7 @@ namespace graphene { namespace chain {
smart_ref<fee_schedule> current_fees; ///< current schedule of fees smart_ref<fee_schedule> current_fees; ///< current schedule of fees
uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks
uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events
uint32_t committee_proposal_review_period = GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring genesis authority may not be signed, prior to expiration uint32_t committee_proposal_review_period = GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring committee authority may not be signed, prior to expiration
uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction
uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block
uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM
@ -45,7 +45,7 @@ namespace graphene { namespace chain {
uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist
uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset
uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses
uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active delegates uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active committee_members
uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have
uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation
uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network
@ -89,7 +89,7 @@ namespace graphene { namespace chain {
FC_ASSERT( maximum_time_until_expiration > block_interval, FC_ASSERT( maximum_time_until_expiration > block_interval,
"Maximum transaction expiration time must be greater than a block interval" ); "Maximum transaction expiration time must be greater than a block interval" );
FC_ASSERT( maximum_proposal_lifetime - committee_proposal_review_period > block_interval, FC_ASSERT( maximum_proposal_lifetime - committee_proposal_review_period > block_interval,
"Genesis proposal review period must be less than the maximum proposal lifetime" ); "Committee proposal review period must be less than the maximum proposal lifetime" );
} }
}; };

View file

@ -0,0 +1,59 @@
#pragma once
#include <graphene/chain/protocol/base.hpp>
#include <graphene/chain/protocol/chain_parameters.hpp>
namespace graphene { namespace chain {
/**
* @brief Create a committee_member object, as a bid to hold a committee_member seat on the network.
* @ingroup operations
*
* Accounts which wish to become committee_members may use this operation to create a committee_member object which stakeholders may
* vote on to approve its position as a committee_member.
*/
struct committee_member_create_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
/// The account which owns the committee_member. This account pays the fee for this operation.
account_id_type committee_member_account;
string url;
account_id_type fee_payer()const { return committee_member_account; }
void validate()const;
};
/**
* @brief Used by committee_members to update the global parameters of the blockchain.
* @ingroup operations
*
* This operation allows the committee_members to update the global parameters on the blockchain. These control various
* tunable aspects of the chain, including block and maintenance intervals, maximum data sizes, the fees charged by
* the network, etc.
*
* This operation may only be used in a proposed transaction, and a proposed transaction which contains this
* operation must have a review period specified in the current global parameters before it may be accepted.
*/
struct committee_member_update_global_parameters_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
chain_parameters new_parameters;
account_id_type fee_payer()const { return account_id_type(); }
void validate()const;
};
/// TODO: committee_member_resign_operation : public base_operation
} } // graphene::chain
FC_REFLECT( graphene::chain::committee_member_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::committee_member_create_operation,
(fee)(committee_member_account)(url) )
FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation, (fee)(new_parameters) );

View file

@ -1,59 +0,0 @@
#pragma once
#include <graphene/chain/protocol/base.hpp>
#include <graphene/chain/protocol/chain_parameters.hpp>
namespace graphene { namespace chain {
/**
* @brief Create a delegate object, as a bid to hold a delegate seat on the network.
* @ingroup operations
*
* Accounts which wish to become delegates may use this operation to create a delegate object which stakeholders may
* vote on to approve its position as a delegate.
*/
struct delegate_create_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
/// The account which owns the delegate. This account pays the fee for this operation.
account_id_type delegate_account;
string url;
account_id_type fee_payer()const { return delegate_account; }
void validate()const;
};
/**
* @brief Used by delegates to update the global parameters of the blockchain.
* @ingroup operations
*
* This operation allows the delegates to update the global parameters on the blockchain. These control various
* tunable aspects of the chain, including block and maintenance intervals, maximum data sizes, the fees charged by
* the network, etc.
*
* This operation may only be used in a proposed transaction, and a proposed transaction which contains this
* operation must have a review period specified in the current global parameters before it may be accepted.
*/
struct delegate_update_global_parameters_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
chain_parameters new_parameters;
account_id_type fee_payer()const { return account_id_type(); }
void validate()const;
};
/// TODO: delegate_resign_operation : public base_operation
} } // graphene::chain
FC_REFLECT( graphene::chain::delegate_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::delegate_update_global_parameters_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::delegate_create_operation,
(fee)(delegate_account)(url) )
FC_REFLECT( graphene::chain::delegate_update_global_parameters_operation, (fee)(new_parameters) );

View file

@ -6,7 +6,7 @@
#include <graphene/chain/protocol/asset_ops.hpp> #include <graphene/chain/protocol/asset_ops.hpp>
#include <graphene/chain/protocol/balance.hpp> #include <graphene/chain/protocol/balance.hpp>
#include <graphene/chain/protocol/custom.hpp> #include <graphene/chain/protocol/custom.hpp>
#include <graphene/chain/protocol/delegate.hpp> #include <graphene/chain/protocol/committee_member.hpp>
#include <graphene/chain/protocol/market.hpp> #include <graphene/chain/protocol/market.hpp>
#include <graphene/chain/protocol/proposal.hpp> #include <graphene/chain/protocol/proposal.hpp>
#include <graphene/chain/protocol/transfer.hpp> #include <graphene/chain/protocol/transfer.hpp>
@ -52,8 +52,8 @@ namespace graphene { namespace chain {
withdraw_permission_update_operation, withdraw_permission_update_operation,
withdraw_permission_claim_operation, withdraw_permission_claim_operation,
withdraw_permission_delete_operation, withdraw_permission_delete_operation,
delegate_create_operation, committee_member_create_operation,
delegate_update_global_parameters_operation, committee_member_update_global_parameters_operation,
vesting_balance_create_operation, vesting_balance_create_operation,
vesting_balance_withdraw_operation, vesting_balance_withdraw_operation,
worker_create_operation, worker_create_operation,

View file

@ -57,9 +57,9 @@ namespace graphene { namespace chain {
optional<uint32_t> review_period_seconds; optional<uint32_t> review_period_seconds;
extensions_type extensions; extensions_type extensions;
/// Constructs a proposal_create_operation suitable for genesis proposals, with fee, expiration time and review /// Constructs a proposal_create_operation suitable for committee proposals, with fee, expiration time and review
/// period set appropriately. /// period set appropriately.
static proposal_create_operation genesis_proposal(const chain_parameters& param, fc::time_point_sec head_block_time ); static proposal_create_operation committee_proposal(const chain_parameters& param, fc::time_point_sec head_block_time );
account_id_type fee_payer()const { return fee_paying_account; } account_id_type fee_payer()const { return fee_paying_account; }
void validate()const; void validate()const;

View file

@ -112,7 +112,7 @@ namespace graphene { namespace chain {
account_object_type, account_object_type,
asset_object_type, asset_object_type,
force_settlement_object_type, force_settlement_object_type,
delegate_object_type, committee_member_object_type,
witness_object_type, witness_object_type,
limit_order_object_type, limit_order_object_type,
call_order_object_type, call_order_object_type,
@ -133,7 +133,7 @@ namespace graphene { namespace chain {
impl_index_meta_object_type, impl_index_meta_object_type,
impl_asset_dynamic_data_type, impl_asset_dynamic_data_type,
impl_asset_bitasset_data_type, impl_asset_bitasset_data_type,
impl_delegate_feeds_object_type, impl_committee_member_feeds_object_type,
impl_account_balance_object_type, impl_account_balance_object_type,
impl_account_statistics_object_type, impl_account_statistics_object_type,
impl_account_debt_object_type, impl_account_debt_object_type,
@ -155,7 +155,7 @@ namespace graphene { namespace chain {
//typedef fc::unsigned_int object_id_type; //typedef fc::unsigned_int object_id_type;
//typedef uint64_t object_id_type; //typedef uint64_t object_id_type;
class account_object; class account_object;
class delegate_object; class committee_member_object;
class witness_object; class witness_object;
class asset_object; class asset_object;
class force_settlement_object; class force_settlement_object;
@ -173,7 +173,7 @@ namespace graphene { namespace chain {
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type;
typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type;
typedef object_id< protocol_ids, delegate_object_type, delegate_object> delegate_id_type; typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type;
typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type;
typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type;
typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type;
@ -365,7 +365,7 @@ FC_REFLECT_ENUM( graphene::chain::object_type,
(account_object_type) (account_object_type)
(force_settlement_object_type) (force_settlement_object_type)
(asset_object_type) (asset_object_type)
(delegate_object_type) (committee_member_object_type)
(witness_object_type) (witness_object_type)
(limit_order_object_type) (limit_order_object_type)
(call_order_object_type) (call_order_object_type)
@ -384,7 +384,7 @@ FC_REFLECT_ENUM( graphene::chain::impl_object_type,
(impl_index_meta_object_type) (impl_index_meta_object_type)
(impl_asset_dynamic_data_type) (impl_asset_dynamic_data_type)
(impl_asset_bitasset_data_type) (impl_asset_bitasset_data_type)
(impl_delegate_feeds_object_type) (impl_committee_member_feeds_object_type)
(impl_account_balance_object_type) (impl_account_balance_object_type)
(impl_account_statistics_object_type) (impl_account_statistics_object_type)
(impl_account_debt_object_type) (impl_account_debt_object_type)
@ -401,7 +401,7 @@ FC_REFLECT_TYPENAME( graphene::chain::share_type )
FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) FC_REFLECT_TYPENAME( graphene::chain::account_id_type )
FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) FC_REFLECT_TYPENAME( graphene::chain::asset_id_type )
FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type )
FC_REFLECT_TYPENAME( graphene::chain::delegate_id_type ) FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type )
FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) FC_REFLECT_TYPENAME( graphene::chain::witness_id_type )
FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type )
FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type )

View file

@ -15,7 +15,7 @@ namespace graphene { namespace chain {
struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; }; struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee; asset fee;
/// The account which owns the delegate. This account pays the fee for this operation. /// The account which owns the witness. This account pays the fee for this operation.
account_id_type witness_account; account_id_type witness_account;
string url; string url;
public_key_type block_signing_key; public_key_type block_signing_key;

View file

@ -35,7 +35,7 @@ void_result proposal_create_evaluator::do_evaluate(const proposal_create_operati
"Proposal review period must be less than its overall lifetime." ); "Proposal review period must be less than its overall lifetime." );
{ {
// If we're dealing with the genesis authority, make sure this transaction has a sufficient review period. // If we're dealing with the committee authority, make sure this transaction has a sufficient review period.
flat_set<account_id_type> auths; flat_set<account_id_type> auths;
vector<authority> other; vector<authority> other;
for( auto& op : o.proposed_ops ) for( auto& op : o.proposed_ops )

View file

@ -1,15 +1,15 @@
/* Copyright (C) Cryptonomex, Inc - All Rights Reserved **/ /* Copyright (C) Cryptonomex, Inc - All Rights Reserved **/
#include <graphene/chain/protocol/delegate.hpp> #include <graphene/chain/protocol/committee_member.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
void delegate_create_operation::validate()const void committee_member_create_operation::validate()const
{ {
FC_ASSERT( fee.amount >= 0 ); FC_ASSERT( fee.amount >= 0 );
FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH ); FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH );
} }
void delegate_update_global_parameters_operation::validate() const void committee_member_update_global_parameters_operation::validate() const
{ {
FC_ASSERT( fee.amount >= 0 ); FC_ASSERT( fee.amount >= 0 );
new_parameters.validate(); new_parameters.validate();

View file

@ -4,7 +4,7 @@
namespace graphene { namespace chain { namespace graphene { namespace chain {
proposal_create_operation proposal_create_operation::genesis_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time ) proposal_create_operation proposal_create_operation::committee_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time )
{ {
proposal_create_operation op; proposal_create_operation op;
op.expiration_time = head_block_time + global_params.maximum_proposal_lifetime; op.expiration_time = head_block_time + global_params.maximum_proposal_lifetime;

View file

@ -18,7 +18,7 @@
#include <graphene/chain/transaction_evaluation_state.hpp> #include <graphene/chain/transaction_evaluation_state.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>

View file

@ -17,7 +17,7 @@
*/ */
#include <graphene/chain/witness_evaluator.hpp> #include <graphene/chain/witness_evaluator.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>

@ -1 +1 @@
Subproject commit 2ef7583f90b8593511dda23133ed5600f5add392 Subproject commit 0391665471b4dffb7af951853a777565a7ae9a74

View file

@ -47,7 +47,6 @@
#define GRAPHENE_NET_TEST_P2P_PORT 1700 #define GRAPHENE_NET_TEST_P2P_PORT 1700
#define GRAPHENE_NET_DEFAULT_P2P_PORT 1776 #define GRAPHENE_NET_DEFAULT_P2P_PORT 1776
#define GRAPHENE_NET_DEFAULT_DESIRED_CONNECTIONS 20 #define GRAPHENE_NET_DEFAULT_DESIRED_CONNECTIONS 20
#define GRAPHENE_NET_DELEGATE_DESIRED_CONNECTIONS 50
#define GRAPHENE_NET_DEFAULT_MAX_CONNECTIONS 200 #define GRAPHENE_NET_DEFAULT_MAX_CONNECTIONS 200
#define GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES (1024 * 1024) #define GRAPHENE_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES (1024 * 1024)

View file

@ -1431,16 +1431,16 @@ namespace graphene { namespace net { namespace detail {
{ {
_average_network_usage_second_counter = 0; _average_network_usage_second_counter = 0;
++_average_network_usage_minute_counter; ++_average_network_usage_minute_counter;
uint32_t average_read_this_minute = (uint32_t)boost::accumulate(_average_network_read_speed_seconds, UINT64_C(0)) / (uint32_t)_average_network_read_speed_seconds.size(); uint32_t average_read_this_minute = (uint32_t)boost::accumulate(_average_network_read_speed_seconds, uint64_t(0)) / (uint32_t)_average_network_read_speed_seconds.size();
_average_network_read_speed_minutes.push_back(average_read_this_minute); _average_network_read_speed_minutes.push_back(average_read_this_minute);
uint32_t average_written_this_minute = (uint32_t)boost::accumulate(_average_network_write_speed_seconds, UINT64_C(0)) / (uint32_t)_average_network_write_speed_seconds.size(); uint32_t average_written_this_minute = (uint32_t)boost::accumulate(_average_network_write_speed_seconds, uint64_t(0)) / (uint32_t)_average_network_write_speed_seconds.size();
_average_network_write_speed_minutes.push_back(average_written_this_minute); _average_network_write_speed_minutes.push_back(average_written_this_minute);
if (_average_network_usage_minute_counter >= 60) if (_average_network_usage_minute_counter >= 60)
{ {
_average_network_usage_minute_counter = 0; _average_network_usage_minute_counter = 0;
uint32_t average_read_this_hour = (uint32_t)boost::accumulate(_average_network_read_speed_minutes, UINT64_C(0)) / (uint32_t)_average_network_read_speed_minutes.size(); uint32_t average_read_this_hour = (uint32_t)boost::accumulate(_average_network_read_speed_minutes, uint64_t(0)) / (uint32_t)_average_network_read_speed_minutes.size();
_average_network_read_speed_hours.push_back(average_read_this_hour); _average_network_read_speed_hours.push_back(average_read_this_hour);
uint32_t average_written_this_hour = (uint32_t)boost::accumulate(_average_network_write_speed_minutes, UINT64_C(0)) / (uint32_t)_average_network_write_speed_minutes.size(); uint32_t average_written_this_hour = (uint32_t)boost::accumulate(_average_network_write_speed_minutes, uint64_t(0)) / (uint32_t)_average_network_write_speed_minutes.size();
_average_network_write_speed_hours.push_back(average_written_this_hour); _average_network_write_speed_hours.push_back(average_written_this_hour);
} }
} }

View file

@ -1,4 +1,4 @@
file(GLOB HEADERS "include/graphene/delegate/*.hpp") file(GLOB HEADERS "include/graphene/witness/*.hpp")
add_library( graphene_witness add_library( graphene_witness
witness.cpp witness.cpp

View file

@ -64,4 +64,4 @@ private:
fc::future<void> _block_production_task; fc::future<void> _block_production_task;
}; };
} } //graphene::delegate } } //graphene::witness_plugin

View file

@ -150,7 +150,7 @@ void witness_plugin::plugin_shutdown()
void witness_plugin::schedule_next_production(const graphene::chain::chain_parameters& global_parameters) void witness_plugin::schedule_next_production(const graphene::chain::chain_parameters& global_parameters)
{ {
//Get next production time for *any* delegate //Get next production time for *any* witness
auto block_interval = global_parameters.block_interval; auto block_interval = global_parameters.block_interval;
fc::time_point next_block_time = fc::time_point_sec() + fc::time_point next_block_time = fc::time_point_sec() +
(graphene::time::now().sec_since_epoch() / block_interval + 1) * block_interval; (graphene::time::now().sec_since_epoch() / block_interval + 1) * block_interval;
@ -158,7 +158,7 @@ void witness_plugin::schedule_next_production(const graphene::chain::chain_param
if( graphene::time::ntp_time().valid() ) if( graphene::time::ntp_time().valid() )
next_block_time -= graphene::time::ntp_error(); next_block_time -= graphene::time::ntp_error();
//Sleep until the next production time for *any* delegate //Sleep until the next production time for *any* witness
_block_production_task = fc::schedule([this]{block_production_loop();}, _block_production_task = fc::schedule([this]{block_production_loop();},
next_block_time, "Witness Block Production"); next_block_time, "Witness Block Production");
} }

View file

@ -18,7 +18,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
@ -62,8 +62,8 @@ object* create_object( const variant& v )
return create_object_of_type< asset_object >( v ); return create_object_of_type< asset_object >( v );
case force_settlement_object_type: case force_settlement_object_type:
return create_object_of_type< force_settlement_object >( v ); return create_object_of_type< force_settlement_object >( v );
case delegate_object_type: case committee_member_object_type:
return create_object_of_type< delegate_object >( v ); return create_object_of_type< committee_member_object >( v );
case witness_object_type: case witness_object_type:
return create_object_of_type< witness_object >( v ); return create_object_of_type< witness_object >( v );
case limit_order_object_type: case limit_order_object_type:

View file

@ -182,7 +182,7 @@ class wallet_api
/** Returns the block chain's slowly-changing settings. /** Returns the block chain's slowly-changing settings.
* This object contains all of the properties of the blockchain that are fixed * This object contains all of the properties of the blockchain that are fixed
* or that change only once per maintenance interval (daily) such as the * or that change only once per maintenance interval (daily) such as the
* current list of witnesses, delegates, block interval, etc. * current list of witnesses, committee_members, block interval, etc.
* @see \c get_dynamic_global_properties() for frequently changing properties * @see \c get_dynamic_global_properties() for frequently changing properties
* @returns the global properties * @returns the global properties
*/ */
@ -686,7 +686,7 @@ class wallet_api
* *
* Price feed providers use this command to publish their price feeds for market-issued assets. A price feed is * Price feed providers use this command to publish their price feeds for market-issued assets. A price feed is
* used to tune the market for a particular market-issued asset. For each value in the feed, the median across all * used to tune the market for a particular market-issued asset. For each value in the feed, the median across all
* delegate feeds for that asset is calculated and the market for the asset is configured with the median of that * committee_member feeds for that asset is calculated and the market for the asset is configured with the median of that
* value. * value.
* *
* The feed object in this command contains three prices: a call price limit, a short price limit, and a settlement price. * The feed object in this command contains three prices: a call price limit, a short price limit, and a settlement price.
@ -807,17 +807,17 @@ class wallet_api
account_whitelist_operation::account_listing new_listing_status, account_whitelist_operation::account_listing new_listing_status,
bool broadcast = false); bool broadcast = false);
/** Creates a delegate object owned by the given account. /** Creates a committee_member object owned by the given account.
* *
* An account can have at most one delegate object. * An account can have at most one committee_member object.
* *
* @param owner_account the name or id of the account which is creating the delegate * @param owner_account the name or id of the account which is creating the committee_member
* @param url a URL to include in the delegate record in the blockchain. Clients may * @param url a URL to include in the committee_member record in the blockchain. Clients may
* display this when showing a list of delegates. May be blank. * display this when showing a list of committee_members. May be blank.
* @param broadcast true to broadcast the transaction on the network * @param broadcast true to broadcast the transaction on the network
* @returns the signed transaction registering a delegate * @returns the signed transaction registering a committee_member
*/ */
signed_transaction create_delegate(string owner_account, signed_transaction create_committee_member(string owner_account,
string url, string url,
bool broadcast = false); bool broadcast = false);
@ -836,20 +836,20 @@ class wallet_api
*/ */
map<string,witness_id_type> list_witnesses(const string& lowerbound, uint32_t limit); map<string,witness_id_type> list_witnesses(const string& lowerbound, uint32_t limit);
/** Lists all delegates registered in the blockchain. /** Lists all committee_members registered in the blockchain.
* This returns a list of all account names that own delegates, and the associated delegate id, * This returns a list of all account names that own committee_members, and the associated committee_member id,
* sorted by name. This lists delegates whether they are currently voted in or not. * sorted by name. This lists committee_members whether they are currently voted in or not.
* *
* Use the \c lowerbound and limit parameters to page through the list. To retrieve all delegates, * Use the \c lowerbound and limit parameters to page through the list. To retrieve all committee_members,
* start by setting \c lowerbound to the empty string \c "", and then each iteration, pass * start by setting \c lowerbound to the empty string \c "", and then each iteration, pass
* the last delegate name returned as the \c lowerbound for the next \c list_delegates() call. * the last committee_member name returned as the \c lowerbound for the next \c list_committee_members() call.
* *
* @param lowerbound the name of the first delegate to return. If the named delegate does not exist, * @param lowerbound the name of the first committee_member to return. If the named committee_member does not exist,
* the list will start at the delegate that comes after \c lowerbound * the list will start at the committee_member that comes after \c lowerbound
* @param limit the maximum number of delegates to return (max: 1000) * @param limit the maximum number of committee_members to return (max: 1000)
* @returns a list of delegates mapping delegate names to delegate ids * @returns a list of committee_members mapping committee_member names to committee_member ids
*/ */
map<string, delegate_id_type> list_delegates(const string& lowerbound, uint32_t limit); map<string, committee_member_id_type> list_committee_members(const string& lowerbound, uint32_t limit);
/** Returns information about the given witness. /** Returns information about the given witness.
* @param owner_account the name or id of the witness account owner, or the id of the witness * @param owner_account the name or id of the witness account owner, or the id of the witness
@ -857,11 +857,11 @@ class wallet_api
*/ */
witness_object get_witness(string owner_account); witness_object get_witness(string owner_account);
/** Returns information about the given delegate. /** Returns information about the given committee_member.
* @param owner_account the name or id of the delegate account owner, or the id of the delegate * @param owner_account the name or id of the committee_member account owner, or the id of the committee_member
* @returns the information about the delegate stored in the block chain * @returns the information about the committee_member stored in the block chain
*/ */
delegate_object get_delegate(string owner_account); committee_member_object get_committee_member(string owner_account);
/** Creates a witness object owned by the given account. /** Creates a witness object owned by the given account.
* *
@ -877,25 +877,25 @@ class wallet_api
string url, string url,
bool broadcast = false); bool broadcast = false);
/** Vote for a given delegate. /** Vote for a given committee_member.
* *
* An account can publish a list of all delegatees they approve of. This * An account can publish a list of all committee_memberes they approve of. This
* command allows you to add or remove delegatees from this list. * command allows you to add or remove committee_memberes from this list.
* Each account's vote is weighted according to the number of shares of the * Each account's vote is weighted according to the number of shares of the
* core asset owned by that account at the time the votes are tallied. * core asset owned by that account at the time the votes are tallied.
* *
* @note you cannot vote against a delegate, you can only vote for the delegate * @note you cannot vote against a committee_member, you can only vote for the committee_member
* or not vote for the delegate. * or not vote for the committee_member.
* *
* @param voting_account the name or id of the account who is voting with their shares * @param voting_account the name or id of the account who is voting with their shares
* @param delegate the name or id of the delegate' owner account * @param committee_member the name or id of the committee_member' owner account
* @param approve true if you wish to vote in favor of that delegate, false to * @param approve true if you wish to vote in favor of that committee_member, false to
* remove your vote in favor of that delegate * remove your vote in favor of that committee_member
* @param broadcast true if you wish to broadcast the transaction * @param broadcast true if you wish to broadcast the transaction
* @return the signed transaction changing your vote for the given delegate * @return the signed transaction changing your vote for the given committee_member
*/ */
signed_transaction vote_for_delegate(string voting_account, signed_transaction vote_for_committee_member(string voting_account,
string delegate, string committee_member,
bool approve, bool approve,
bool broadcast = false); bool broadcast = false);
@ -943,13 +943,13 @@ class wallet_api
optional<string> voting_account, optional<string> voting_account,
bool broadcast = false); bool broadcast = false);
/** Set your vote for the number of witnesses and delegates in the system. /** Set your vote for the number of witnesses and committee_members in the system.
* *
* Each account can voice their opinion on how many delegates and how many * Each account can voice their opinion on how many committee_members and how many
* witnesses there should be in the active delegate/active witness list. These * witnesses there should be in the active committee_member/active witness list. These
* are independent of each other. You must vote your approval of at least as many * are independent of each other. You must vote your approval of at least as many
* delegates or witnesses as you claim there should be (you can't say that there should * committee_members or witnesses as you claim there should be (you can't say that there should
* be 20 delegates but only vote for 10). * be 20 committee_members but only vote for 10).
* *
* There are maximum values for each set in the blockchain parameters (currently * There are maximum values for each set in the blockchain parameters (currently
* defaulting to 1001). * defaulting to 1001).
@ -958,14 +958,14 @@ class wallet_api
* set, your preferences will be ignored. * set, your preferences will be ignored.
* *
* @param account_to_modify the name or id of the account to update * @param account_to_modify the name or id of the account to update
* @param number_of_delegates the number * @param number_of_committee_members the number
* *
* @param broadcast true if you wish to broadcast the transaction * @param broadcast true if you wish to broadcast the transaction
* @return the signed transaction changing your vote proxy settings * @return the signed transaction changing your vote proxy settings
*/ */
signed_transaction set_desired_witness_and_delegate_count(string account_to_modify, signed_transaction set_desired_witness_and_committee_member_count(string account_to_modify,
uint16_t desired_number_of_witnesses, uint16_t desired_number_of_witnesses,
uint16_t desired_number_of_delegates, uint16_t desired_number_of_committee_members,
bool broadcast = false); bool broadcast = false);
/** Signs a transaction. /** Signs a transaction.
@ -1070,16 +1070,16 @@ FC_API( graphene::wallet::wallet_api,
(global_settle_asset) (global_settle_asset)
(settle_asset) (settle_asset)
(whitelist_account) (whitelist_account)
(create_delegate) (create_committee_member)
(get_witness) (get_witness)
(get_delegate) (get_committee_member)
(list_witnesses) (list_witnesses)
(list_delegates) (list_committee_members)
(create_witness) (create_witness)
(vote_for_delegate) (vote_for_committee_member)
(vote_for_witness) (vote_for_witness)
(set_voting_proxy) (set_voting_proxy)
(set_desired_witness_and_delegate_count) (set_desired_witness_and_committee_member_count)
(get_account) (get_account)
(get_account_id) (get_account_id)
(get_block) (get_block)

View file

@ -400,7 +400,7 @@ public:
result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time);
result["chain_id"] = global_props.chain_id; result["chain_id"] = global_props.chain_id;
result["active_witnesses"] = global_props.active_witnesses; result["active_witnesses"] = global_props.active_witnesses;
result["active_delegates"] = global_props.active_delegates; result["active_committee_members"] = global_props.active_committee_members;
result["entropy"] = dynamic_props.random; result["entropy"] = dynamic_props.random;
return result; return result;
} }
@ -1117,18 +1117,18 @@ public:
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} FC_CAPTURE_AND_RETHROW( (authorizing_account)(account_to_list)(new_listing_status)(broadcast) ) } } FC_CAPTURE_AND_RETHROW( (authorizing_account)(account_to_list)(new_listing_status)(broadcast) ) }
signed_transaction create_delegate(string owner_account, string url, signed_transaction create_committee_member(string owner_account, string url,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
delegate_create_operation delegate_create_op; committee_member_create_operation committee_member_create_op;
delegate_create_op.delegate_account = get_account_id(owner_account); committee_member_create_op.committee_member_account = get_account_id(owner_account);
delegate_create_op.url = url; committee_member_create_op.url = url;
if (_remote_db->get_delegate_by_account(delegate_create_op.delegate_account)) if (_remote_db->get_committee_member_by_account(committee_member_create_op.committee_member_account))
FC_THROW("Account ${owner_account} is already a delegate", ("owner_account", owner_account)); FC_THROW("Account ${owner_account} is already a committee_member", ("owner_account", owner_account));
signed_transaction tx; signed_transaction tx;
tx.operations.push_back( delegate_create_op ); tx.operations.push_back( committee_member_create_op );
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
tx.validate(); tx.validate();
@ -1170,19 +1170,19 @@ public:
FC_CAPTURE_AND_RETHROW( (owner_account) ) FC_CAPTURE_AND_RETHROW( (owner_account) )
} }
delegate_object get_delegate(string owner_account) committee_member_object get_committee_member(string owner_account)
{ {
try try
{ {
fc::optional<delegate_id_type> delegate_id = maybe_id<delegate_id_type>(owner_account); fc::optional<committee_member_id_type> committee_member_id = maybe_id<committee_member_id_type>(owner_account);
if (delegate_id) if (committee_member_id)
{ {
std::vector<delegate_id_type> ids_to_get; std::vector<committee_member_id_type> ids_to_get;
ids_to_get.push_back(*delegate_id); ids_to_get.push_back(*committee_member_id);
std::vector<fc::optional<delegate_object>> delegate_objects = _remote_db->get_delegates(ids_to_get); std::vector<fc::optional<committee_member_object>> committee_member_objects = _remote_db->get_committee_members(ids_to_get);
if (delegate_objects.front()) if (committee_member_objects.front())
return *delegate_objects.front(); return *committee_member_objects.front();
FC_THROW("No delegate is registered for id ${id}", ("id", owner_account)); FC_THROW("No committee_member is registered for id ${id}", ("id", owner_account));
} }
else else
{ {
@ -1190,15 +1190,15 @@ public:
try try
{ {
account_id_type owner_account_id = get_account_id(owner_account); account_id_type owner_account_id = get_account_id(owner_account);
fc::optional<delegate_object> delegate = _remote_db->get_delegate_by_account(owner_account_id); fc::optional<committee_member_object> committee_member = _remote_db->get_committee_member_by_account(owner_account_id);
if (delegate) if (committee_member)
return *delegate; return *committee_member;
else else
FC_THROW("No delegate is registered for account ${account}", ("account", owner_account)); FC_THROW("No committee_member is registered for account ${account}", ("account", owner_account));
} }
catch (const fc::exception&) catch (const fc::exception&)
{ {
FC_THROW("No account or delegate named ${account}", ("account", owner_account)); FC_THROW("No account or committee_member named ${account}", ("account", owner_account));
} }
} }
} }
@ -1238,27 +1238,27 @@ public:
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) } } FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) }
signed_transaction vote_for_delegate(string voting_account, signed_transaction vote_for_committee_member(string voting_account,
string delegate, string committee_member,
bool approve, bool approve,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
account_object voting_account_object = get_account(voting_account); account_object voting_account_object = get_account(voting_account);
account_id_type delegate_owner_account_id = get_account_id(delegate); account_id_type committee_member_owner_account_id = get_account_id(committee_member);
fc::optional<delegate_object> delegate_obj = _remote_db->get_delegate_by_account(delegate_owner_account_id); fc::optional<committee_member_object> committee_member_obj = _remote_db->get_committee_member_by_account(committee_member_owner_account_id);
if (!delegate_obj) if (!committee_member_obj)
FC_THROW("Account ${delegate} is not registered as a delegate", ("delegate", delegate)); FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member));
if (approve) if (approve)
{ {
auto insert_result = voting_account_object.options.votes.insert(delegate_obj->vote_id); auto insert_result = voting_account_object.options.votes.insert(committee_member_obj->vote_id);
if (!insert_result.second) if (!insert_result.second)
FC_THROW("Account ${account} was already voting for delegate ${delegate}", ("account", voting_account)("delegate", delegate)); FC_THROW("Account ${account} was already voting for committee_member ${committee_member}", ("account", voting_account)("committee_member", committee_member));
} }
else else
{ {
unsigned votes_removed = voting_account_object.options.votes.erase(delegate_obj->vote_id); unsigned votes_removed = voting_account_object.options.votes.erase(committee_member_obj->vote_id);
if (!votes_removed) if (!votes_removed)
FC_THROW("Account ${account} is already not voting for delegate ${delegate}", ("account", voting_account)("delegate", delegate)); FC_THROW("Account ${account} is already not voting for committee_member ${committee_member}", ("account", voting_account)("committee_member", committee_member));
} }
account_update_operation account_update_op; account_update_operation account_update_op;
account_update_op.account = voting_account_object.id; account_update_op.account = voting_account_object.id;
@ -1270,7 +1270,7 @@ public:
tx.validate(); tx.validate();
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} FC_CAPTURE_AND_RETHROW( (voting_account)(delegate)(approve)(broadcast) ) } } FC_CAPTURE_AND_RETHROW( (voting_account)(committee_member)(approve)(broadcast) ) }
signed_transaction vote_for_witness(string voting_account, signed_transaction vote_for_witness(string voting_account,
string witness, string witness,
@ -1337,19 +1337,19 @@ public:
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} FC_CAPTURE_AND_RETHROW( (account_to_modify)(voting_account)(broadcast) ) } } FC_CAPTURE_AND_RETHROW( (account_to_modify)(voting_account)(broadcast) ) }
signed_transaction set_desired_witness_and_delegate_count(string account_to_modify, signed_transaction set_desired_witness_and_committee_member_count(string account_to_modify,
uint16_t desired_number_of_witnesses, uint16_t desired_number_of_witnesses,
uint16_t desired_number_of_delegates, uint16_t desired_number_of_committee_members,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
account_object account_object_to_modify = get_account(account_to_modify); account_object account_object_to_modify = get_account(account_to_modify);
if (account_object_to_modify.options.num_witness == desired_number_of_witnesses && if (account_object_to_modify.options.num_witness == desired_number_of_witnesses &&
account_object_to_modify.options.num_committee == desired_number_of_delegates) account_object_to_modify.options.num_committee == desired_number_of_committee_members)
FC_THROW("Account ${account} is already voting for ${witnesses} witnesses and ${delegates} delegates", FC_THROW("Account ${account} is already voting for ${witnesses} witnesses and ${committee_members} committee_members",
("account", account_to_modify)("witnesses", desired_number_of_witnesses)("delegates",desired_number_of_witnesses)); ("account", account_to_modify)("witnesses", desired_number_of_witnesses)("committee_members",desired_number_of_witnesses));
account_object_to_modify.options.num_witness = desired_number_of_witnesses; account_object_to_modify.options.num_witness = desired_number_of_witnesses;
account_object_to_modify.options.num_committee = desired_number_of_delegates; account_object_to_modify.options.num_committee = desired_number_of_committee_members;
account_update_operation account_update_op; account_update_operation account_update_op;
account_update_op.account = account_object_to_modify.id; account_update_op.account = account_object_to_modify.id;
@ -1361,7 +1361,7 @@ public:
tx.validate(); tx.validate();
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} FC_CAPTURE_AND_RETHROW( (account_to_modify)(desired_number_of_witnesses)(desired_number_of_delegates)(broadcast) ) } } FC_CAPTURE_AND_RETHROW( (account_to_modify)(desired_number_of_witnesses)(desired_number_of_committee_members)(broadcast) ) }
signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false) signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false)
{ {
@ -2095,10 +2095,10 @@ signed_transaction wallet_api::whitelist_account(string authorizing_account,
return my->whitelist_account(authorizing_account, account_to_list, new_listing_status, broadcast); return my->whitelist_account(authorizing_account, account_to_list, new_listing_status, broadcast);
} }
signed_transaction wallet_api::create_delegate(string owner_account, string url, signed_transaction wallet_api::create_committee_member(string owner_account, string url,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->create_delegate(owner_account, url, broadcast); return my->create_committee_member(owner_account, url, broadcast);
} }
map<string,witness_id_type> wallet_api::list_witnesses(const string& lowerbound, uint32_t limit) map<string,witness_id_type> wallet_api::list_witnesses(const string& lowerbound, uint32_t limit)
@ -2106,9 +2106,9 @@ map<string,witness_id_type> wallet_api::list_witnesses(const string& lowerbound,
return my->_remote_db->lookup_witness_accounts(lowerbound, limit); return my->_remote_db->lookup_witness_accounts(lowerbound, limit);
} }
map<string,delegate_id_type> wallet_api::list_delegates(const string& lowerbound, uint32_t limit) map<string,committee_member_id_type> wallet_api::list_committee_members(const string& lowerbound, uint32_t limit)
{ {
return my->_remote_db->lookup_delegate_accounts(lowerbound, limit); return my->_remote_db->lookup_committee_member_accounts(lowerbound, limit);
} }
witness_object wallet_api::get_witness(string owner_account) witness_object wallet_api::get_witness(string owner_account)
@ -2116,9 +2116,9 @@ witness_object wallet_api::get_witness(string owner_account)
return my->get_witness(owner_account); return my->get_witness(owner_account);
} }
delegate_object wallet_api::get_delegate(string owner_account) committee_member_object wallet_api::get_committee_member(string owner_account)
{ {
return my->get_delegate(owner_account); return my->get_committee_member(owner_account);
} }
signed_transaction wallet_api::create_witness(string owner_account, signed_transaction wallet_api::create_witness(string owner_account,
@ -2128,12 +2128,12 @@ signed_transaction wallet_api::create_witness(string owner_account,
return my->create_witness(owner_account, url, broadcast); return my->create_witness(owner_account, url, broadcast);
} }
signed_transaction wallet_api::vote_for_delegate(string voting_account, signed_transaction wallet_api::vote_for_committee_member(string voting_account,
string witness, string witness,
bool approve, bool approve,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->vote_for_delegate(voting_account, witness, approve, broadcast); return my->vote_for_committee_member(voting_account, witness, approve, broadcast);
} }
signed_transaction wallet_api::vote_for_witness(string voting_account, signed_transaction wallet_api::vote_for_witness(string voting_account,
@ -2151,13 +2151,13 @@ signed_transaction wallet_api::set_voting_proxy(string account_to_modify,
return my->set_voting_proxy(account_to_modify, voting_account, broadcast); return my->set_voting_proxy(account_to_modify, voting_account, broadcast);
} }
signed_transaction wallet_api::set_desired_witness_and_delegate_count(string account_to_modify, signed_transaction wallet_api::set_desired_witness_and_committee_member_count(string account_to_modify,
uint16_t desired_number_of_witnesses, uint16_t desired_number_of_witnesses,
uint16_t desired_number_of_delegates, uint16_t desired_number_of_committee_members,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->set_desired_witness_and_delegate_count(account_to_modify, desired_number_of_witnesses, return my->set_desired_witness_and_committee_member_count(account_to_modify, desired_number_of_witnesses,
desired_number_of_delegates, broadcast); desired_number_of_committee_members, broadcast);
} }
void wallet_api::set_wallet_filename(string wallet_filename) void wallet_api::set_wallet_filename(string wallet_filename)
@ -2186,14 +2186,14 @@ operation wallet_api::get_prototype_operation(string operation_name)
return graphene::chain::account_upgrade_operation(); return graphene::chain::account_upgrade_operation();
if (operation_name == "account_transfer_operation") if (operation_name == "account_transfer_operation")
return graphene::chain::account_transfer_operation(); return graphene::chain::account_transfer_operation();
if (operation_name == "delegate_create_operation") if (operation_name == "committee_member_create_operation")
return graphene::chain::delegate_create_operation(); return graphene::chain::committee_member_create_operation();
if (operation_name == "witness_create_operation") if (operation_name == "witness_create_operation")
return graphene::chain::witness_create_operation(); return graphene::chain::witness_create_operation();
if (operation_name == "witness_withdraw_pay_operation") if (operation_name == "witness_withdraw_pay_operation")
return graphene::chain::witness_withdraw_pay_operation(); return graphene::chain::witness_withdraw_pay_operation();
if (operation_name == "delegate_update_global_parameters_operation") if (operation_name == "committee_member_update_global_parameters_operation")
return graphene::chain::delegate_update_global_parameters_operation(); return graphene::chain::committee_member_update_global_parameters_operation();
if (operation_name == "transfer_operation") if (operation_name == "transfer_operation")
return graphene::chain::transfer_operation(); return graphene::chain::transfer_operation();
if (operation_name == "override_transfer_operation") if (operation_name == "override_transfer_operation")

View file

@ -132,9 +132,9 @@ int main( int argc, char** argv )
//fc::configure_logging( cfg ); //fc::configure_logging( cfg );
fc::ecc::private_key genesis_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
idump( (key_to_wif( genesis_private_key ) ) ); idump( (key_to_wif( committee_private_key ) ) );
fc::ecc::private_key nathan_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); fc::ecc::private_key nathan_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
idump( (key_to_wif( nathan_private_key ) ) ); idump( (key_to_wif( nathan_private_key ) ) );

View file

@ -105,9 +105,9 @@ int main( int argc, char** argv )
//fc::configure_logging( cfg ); //fc::configure_logging( cfg );
fc::ecc::private_key genesis_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
idump( (key_to_wif( genesis_private_key ) ) ); idump( (key_to_wif( committee_private_key ) ) );
fc::ecc::private_key nathan_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); fc::ecc::private_key nathan_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
public_key_type nathan_pub_key = nathan_private_key.get_public_key(); public_key_type nathan_pub_key = nathan_private_key.get_public_key();

View file

@ -46,6 +46,7 @@ Account* ChainDataModel::getAccount(qint64 id)
} }
catch ( const fc::exception& e ) catch ( const fc::exception& e )
{ {
edump((e.to_detail_string()));
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) ); Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
} }
}); });
@ -61,7 +62,6 @@ Account* ChainDataModel::getAccount(QString name)
return *itr; return *itr;
} }
auto acct = new Account(this); auto acct = new Account(this);
acct->setProperty("id", --m_account_query_num ); acct->setProperty("id", --m_account_query_num );
acct->setProperty("name", name); acct->setProperty("name", name);
@ -93,11 +93,12 @@ Account* ChainDataModel::getAccount(QString name)
} }
catch ( const fc::exception& e ) catch ( const fc::exception& e )
{ {
edump((e.to_detail_string()));
Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) ); Q_EMIT exceptionThrown( QString::fromStdString(e.to_string()) );
} }
}); });
return nullptr; return acct;
} }
QQmlListProperty<Balance> Account::balances() QQmlListProperty<Balance> Account::balances()

View file

@ -47,8 +47,8 @@ class Balance : public QObject {
class Account : public QObject { class Account : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString name MEMBER name) Q_PROPERTY(QString name MEMBER name NOTIFY nameChanged)
Q_PROPERTY(qint64 id MEMBER id) Q_PROPERTY(qint64 id MEMBER id NOTIFY idChanged)
Q_PROPERTY(QQmlListProperty<Balance> balances READ balances) Q_PROPERTY(QQmlListProperty<Balance> balances READ balances)
QString name; QString name;
@ -63,6 +63,10 @@ public:
qint64 getId()const { return id; } qint64 getId()const { return id; }
QQmlListProperty<Balance> balances(); QQmlListProperty<Balance> balances();
signals:
void nameChanged();
void idChanged();
}; };
struct by_id; struct by_id;

View file

@ -38,14 +38,42 @@ ApplicationWindow {
id: appSettings id: appSettings
category: "appSettings" category: "appSettings"
} }
Connections {
target: app
onExceptionThrown: console.log("Exception from app: " + message)
}
Column {
anchors.centerIn: parent
Button { Button {
text: "Transfer" text: "Transfer"
anchors.centerIn: parent
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() { onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), function() {
console.log("Closed form") console.log("Closed form")
}) })
} }
TextField {
id: nameField
onAccepted: lookupButton.clicked()
focus: true
}
Button {
id: lookupButton
text: "Lookup"
onClicked: {
var acct = app.model.getAccount(nameField.text)
// @disable-check M126
if (acct == null)
console.log("Got back null account")
else if (acct.id >= 0)
console.log(JSON.stringify(acct))
else
console.log("Waiting for result...")
acct.idChanged.connect(function(loadedAcct) {
console.log(JSON.stringify(loadedAcct))
})
}
}
}
FormBox { FormBox {
id: formBox id: formBox

View file

@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( two_node_network )
ilog("Connected!"); ilog("Connected!");
fc::ecc::private_key nathan_key = fc::ecc::private_key::generate(); fc::ecc::private_key nathan_key = fc::ecc::private_key::generate();
fc::ecc::private_key genesis_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
graphene::chain::signed_transaction trx; graphene::chain::signed_transaction trx;
trx.set_expiration(now + fc::seconds(30)); trx.set_expiration(now + fc::seconds(30));
std::shared_ptr<chain::database> db2 = app2.chain_database(); std::shared_ptr<chain::database> db2 = app2.chain_database();
@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( two_node_network )
now += GRAPHENE_DEFAULT_BLOCK_INTERVAL; now += GRAPHENE_DEFAULT_BLOCK_INTERVAL;
app2.p2p_node()->broadcast(graphene::net::block_message(db2->generate_block(now, app2.p2p_node()->broadcast(graphene::net::block_message(db2->generate_block(now,
db2->get_scheduled_witness(1).first, db2->get_scheduled_witness(1).first,
genesis_key, committee_key,
database::skip_nothing))); database::skip_nothing)));
fc::usleep(fc::milliseconds(500)); fc::usleep(fc::milliseconds(500));

View file

@ -83,9 +83,9 @@ BOOST_AUTO_TEST_CASE( genesis_and_persistence_bench )
BOOST_CHECK(db.get_balance(account_id_type(i), asset_id_type()).amount == GRAPHENE_MAX_SHARE_SUPPLY / account_count); BOOST_CHECK(db.get_balance(account_id_type(i), asset_id_type()).amount == GRAPHENE_MAX_SHARE_SUPPLY / account_count);
int blocks_out = 0; int blocks_out = 0;
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto witness_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
auto aw = db.get_global_properties().active_witnesses; auto aw = db.get_global_properties().active_witnesses;
auto b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 ); auto b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, witness_priv_key, ~0 );
start_time = fc::time_point::now(); start_time = fc::time_point::now();
/* TODO: get this buliding again /* TODO: get this buliding again
@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE( genesis_and_persistence_bench )
db.push_transaction(trx, ~0); db.push_transaction(trx, ~0);
aw = db.get_global_properties().active_witnesses; aw = db.get_global_properties().active_witnesses;
b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 ); b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, witness_priv_key, ~0 );
} }
*/ */
ilog("Pushed ${c} blocks (1 op each, no validation) in ${t} milliseconds.", ilog("Pushed ${c} blocks (1 op each, no validation) in ${t} milliseconds.",

View file

@ -25,7 +25,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
@ -62,7 +62,7 @@ database_fixture::database_fixture()
} }
auto ahplugin = app.register_plugin<graphene::account_history::account_history_plugin>(); auto ahplugin = app.register_plugin<graphene::account_history::account_history_plugin>();
auto mhplugin = app.register_plugin<graphene::market_history::market_history_plugin>(); auto mhplugin = app.register_plugin<graphene::market_history::market_history_plugin>();
delegate_pub_key = delegate_priv_key.get_public_key(); init_account_pub_key = init_account_priv_key.get_public_key();
boost::program_options::variables_map options; boost::program_options::variables_map options;
@ -79,11 +79,11 @@ database_fixture::database_fixture()
{ {
auto name = "init"+fc::to_string(i); auto name = "init"+fc::to_string(i);
genesis_state.initial_accounts.emplace_back(name, genesis_state.initial_accounts.emplace_back(name,
delegate_priv_key.get_public_key(), init_account_priv_key.get_public_key(),
delegate_priv_key.get_public_key(), init_account_priv_key.get_public_key(),
true); true);
genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_committee_candidates.push_back({name});
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()});
} }
genesis_state.initial_parameters.current_fees->zero_all_fees(); genesis_state.initial_parameters.current_fees->zero_all_fees();
db.init_genesis(genesis_state); db.init_genesis(genesis_state);
@ -120,9 +120,9 @@ database_fixture::~database_fixture()
fc::ecc::private_key database_fixture::generate_private_key(string seed) fc::ecc::private_key database_fixture::generate_private_key(string seed)
{ {
static const fc::ecc::private_key genesis = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); static const fc::ecc::private_key committee = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
if( seed == "null_key" ) if( seed == "null_key" )
return genesis; return committee;
return fc::ecc::private_key::regenerate(fc::sha256::hash(seed)); return fc::ecc::private_key::regenerate(fc::sha256::hash(seed));
} }
@ -315,7 +315,7 @@ void database_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_i
generate_block(); generate_block();
auto slots_to_miss = db.get_slot_at_time(timestamp) - 1; auto slots_to_miss = db.get_slot_at_time(timestamp) - 1;
if( slots_to_miss <= 0 ) return; if( slots_to_miss <= 0 ) return;
generate_block(~0, delegate_priv_key, slots_to_miss); generate_block(~0, init_account_priv_key, slots_to_miss);
return; return;
} }
while( db.head_block_time() < timestamp ) while( db.head_block_time() < timestamp )
@ -335,15 +335,15 @@ account_create_operation database_fixture::make_account(
create_account.active = authority(321, key, 321); create_account.active = authority(321, key, 321);
create_account.options.memo_key = key; create_account.options.memo_key = key;
auto& active_delegates = db.get_global_properties().active_delegates; auto& active_committee_members = db.get_global_properties().active_committee_members;
if( active_delegates.size() > 0 ) if( active_committee_members.size() > 0 )
{ {
set<vote_id_type> votes; set<vote_id_type> votes;
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
create_account.options.votes = flat_set<vote_id_type>(votes.begin(), votes.end()); create_account.options.votes = flat_set<vote_id_type>(votes.begin(), votes.end());
} }
create_account.options.num_committee = create_account.options.votes.size(); create_account.options.num_committee = create_account.options.votes.size();
@ -373,15 +373,15 @@ account_create_operation database_fixture::make_account(
create_account.active = authority(321, key, 321); create_account.active = authority(321, key, 321);
create_account.options.memo_key = key; create_account.options.memo_key = key;
const vector<delegate_id_type>& active_delegates = db.get_global_properties().active_delegates; const vector<committee_member_id_type>& active_committee_members = db.get_global_properties().active_committee_members;
if( active_delegates.size() > 0 ) if( active_committee_members.size() > 0 )
{ {
set<vote_id_type> votes; set<vote_id_type> votes;
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
votes.insert(active_delegates[rand() % active_delegates.size()](db).vote_id); votes.insert(active_committee_members[rand() % active_committee_members.size()](db).vote_id);
create_account.options.votes = flat_set<vote_id_type>(votes.begin(), votes.end()); create_account.options.votes = flat_set<vote_id_type>(votes.begin(), votes.end());
} }
create_account.options.num_committee = create_account.options.votes.size(); create_account.options.num_committee = create_account.options.votes.size();
@ -568,15 +568,15 @@ const account_object& database_fixture::create_account(
FC_CAPTURE_AND_RETHROW( (name)(registrar_id)(referrer_id) ) FC_CAPTURE_AND_RETHROW( (name)(registrar_id)(referrer_id) )
} }
const delegate_object& database_fixture::create_delegate( const account_object& owner ) const committee_member_object& database_fixture::create_committee_member( const account_object& owner )
{ {
delegate_create_operation op; committee_member_create_operation op;
op.delegate_account = owner.id; op.committee_member_account = owner.id;
trx.operations.push_back(op); trx.operations.push_back(op);
trx.validate(); trx.validate();
processed_transaction ptx = db.push_transaction(trx, ~0); processed_transaction ptx = db.push_transaction(trx, ~0);
trx.operations.clear(); trx.operations.clear();
return db.get<delegate_object>(ptx.operation_results[0].get<object_id_type>()); return db.get<committee_member_object>(ptx.operation_results[0].get<object_id_type>());
} }
const witness_object&database_fixture::create_witness(account_id_type owner, const fc::ecc::private_key& signing_private_key) const witness_object&database_fixture::create_witness(account_id_type owner, const fc::ecc::private_key& signing_private_key)

View file

@ -141,11 +141,11 @@ struct database_fixture {
genesis_state_type genesis_state; genesis_state_type genesis_state;
chain::database &db; chain::database &db;
signed_transaction trx; signed_transaction trx;
public_key_type genesis_key; public_key_type committee_key;
account_id_type genesis_account; account_id_type committee_account;
fc::ecc::private_key private_key = fc::ecc::private_key::generate(); fc::ecc::private_key private_key = fc::ecc::private_key::generate();
fc::ecc::private_key delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); fc::ecc::private_key init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key; public_key_type init_account_pub_key;
optional<fc::temp_directory> data_dir; optional<fc::temp_directory> data_dir;
bool skip_key_index_test = false; bool skip_key_index_test = false;
@ -243,7 +243,7 @@ struct database_fixture {
uint8_t referrer_percent = 100 uint8_t referrer_percent = 100
); );
const delegate_object& create_delegate( const account_object& owner ); const committee_member_object& create_committee_member( const account_object& owner );
const witness_object& create_witness(account_id_type owner, const witness_object& create_witness(account_id_type owner,
const fc::ecc::private_key& signing_private_key = generate_private_key("null_key")); const fc::ecc::private_key& signing_private_key = generate_private_key("null_key"));
const witness_object& create_witness(const account_object& owner, const witness_object& create_witness(const account_object& owner,

View file

@ -43,13 +43,13 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
const asset_object& core = asset_id_type()(db); const asset_object& core = asset_id_type()(db);
uint32_t skip_flags = uint32_t skip_flags =
database::skip_transaction_dupe_check database::skip_transaction_dupe_check
| database::skip_delegate_signature | database::skip_witness_signature
| database::skip_transaction_signatures | database::skip_transaction_signatures
| database::skip_authority_check | database::skip_authority_check
; ;
// Sam is the creator of accounts // Sam is the creator of accounts
private_key_type genesis_key = delegate_priv_key; private_key_type committee_key = init_account_priv_key;
private_key_type sam_key = generate_private_key("sam"); private_key_type sam_key = generate_private_key("sam");
// //
@ -78,9 +78,9 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
transaction tx; transaction tx;
processed_transaction ptx; processed_transaction ptx;
account_object genesis_account_object = genesis_account(db); account_object committee_account_object = committee_account(db);
// transfer from genesis account to Sam account // transfer from committee account to Sam account
transfer(genesis_account_object, sam_account_object, core.amount(100000)); transfer(committee_account_object, sam_account_object, core.amount(100000));
const int num_keys = 5; const int num_keys = 5;
vector< private_key_type > numbered_private_keys; vector< private_key_type > numbered_private_keys;
@ -239,14 +239,14 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
/** /**
* To have a secure random number we need to ensure that the same * To have a secure random number we need to ensure that the same
* delegate does not get to produce two blocks in a row. There is * witness does not get to produce two blocks in a row. There is
* always a chance that the last delegate of one round will be the * always a chance that the last witness of one round will be the
* first delegate of the next round. * first witness of the next round.
* *
* This means that when we shuffle delegates we need to make sure * This means that when we shuffle witness we need to make sure
* that there is at least N/2 delegates between consecutive turns * that there is at least N/2 witness between consecutive turns
* of the same delegate. This means that durring the random * of the same witness. This means that durring the random
* shuffle we need to restrict the placement of delegates to maintain * shuffle we need to restrict the placement of witness to maintain
* this invariant. * this invariant.
* *
* This test checks the requirement using Monte Carlo approach * This test checks the requirement using Monte Carlo approach
@ -316,14 +316,14 @@ BOOST_FIXTURE_TEST_CASE( witness_order_mc_test, database_fixture )
/** /**
* To have a secure random number we need to ensure that the same * To have a secure random number we need to ensure that the same
* delegate does not get to produce two blocks in a row. There is * witness does not get to produce two blocks in a row. There is
* always a chance that the last delegate of one round will be the * always a chance that the last witness of one round will be the
* first delegate of the next round. * first witness of the next round.
* *
* This means that when we shuffle delegates we need to make sure * This means that when we shuffle witness we need to make sure
* that there is at least N/2 delegates between consecutive turns * that there is at least N/2 witness between consecutive turns
* of the same delegate. This means that durring the random * of the same witness. This means that durring the random
* shuffle we need to restrict the placement of delegates to maintain * shuffle we need to restrict the placement of witness to maintain
* this invariant. * this invariant.
* *
* This test checks the requirement using Monte Carlo approach * This test checks the requirement using Monte Carlo approach
@ -410,7 +410,7 @@ BOOST_FIXTURE_TEST_CASE( tapos_rollover, database_fixture )
const auto& core = asset_id_type()(db); const auto& core = asset_id_type()(db);
BOOST_TEST_MESSAGE( "Give Alice some money" ); BOOST_TEST_MESSAGE( "Give Alice some money" );
transfer(genesis_account, alice_id, asset(10000)); transfer(committee_account, alice_id, asset(10000));
generate_block(); generate_block();
BOOST_TEST_MESSAGE( "Generate up to block 0xFF00" ); BOOST_TEST_MESSAGE( "Generate up to block 0xFF00" );

View file

@ -5,7 +5,6 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/db/simple_index.hpp> #include <graphene/db/simple_index.hpp>
@ -34,12 +33,12 @@ BOOST_AUTO_TEST_CASE( transfer_benchmark )
{ {
fc::ecc::private_key nathan_key = fc::ecc::private_key::generate(); fc::ecc::private_key nathan_key = fc::ecc::private_key::generate();
const key_object& key = register_key(nathan_key.get_public_key()); const key_object& key = register_key(nathan_key.get_public_key());
const auto& genesis = account_id_type()(db); const auto& committee_account = account_id_type()(db);
auto start = fc::time_point::now(); auto start = fc::time_point::now();
for( uint32_t i = 0; i < 1000*1000; ++i ) for( uint32_t i = 0; i < 1000*1000; ++i )
{ {
const auto& a = create_account("a"+fc::to_string(i), key.id); const auto& a = create_account("a"+fc::to_string(i), key.id);
transfer( genesis, a, asset(1000) ); transfer( committee_account, a, asset(1000) );
} }
auto end = fc::time_point::now(); auto end = fc::time_point::now();
auto elapsed = end - start; auto elapsed = end - start;

View file

@ -24,7 +24,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/db/simple_index.hpp> #include <graphene/db/simple_index.hpp>
@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts )
BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 2000); BOOST_CHECK_EQUAL(get_balance(child, core), old_balance - 2000);
trx.clear(); trx.clear();
BOOST_TEST_MESSAGE( "Update grandparent account authority to be genesis account" ); BOOST_TEST_MESSAGE( "Update grandparent account authority to be committee account" );
{ {
account_update_operation op; account_update_operation op;
op.account = grandparent.id; op.account = grandparent.id;
@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE( recursive_accounts )
trx.operations.push_back(op); trx.operations.push_back(op);
sign(trx, parent2_key); sign(trx, parent2_key);
sign(trx, grandparent_key); sign(trx, grandparent_key);
sign(trx, delegate_priv_key); sign(trx, init_account_priv_key);
//Fails due to recursion depth. //Fails due to recursion depth.
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception);
BOOST_TEST_MESSAGE( "verify child key can override recursion checks" ); BOOST_TEST_MESSAGE( "verify child key can override recursion checks" );
@ -293,12 +293,12 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
try { try {
INVOKE(any_two_of_three); INVOKE(any_two_of_three);
fc::ecc::private_key genesis_key = delegate_priv_key; fc::ecc::private_key committee_key = init_account_priv_key;
fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1")); fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1"));
fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2")); fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2"));
fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3")); fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3"));
const account_object& moneyman = create_account("moneyman", delegate_pub_key); const account_object& moneyman = create_account("moneyman", init_account_pub_key);
const account_object& nathan = get_account("nathan"); const account_object& nathan = get_account("nathan");
const asset_object& core = asset_id_type()(db); const asset_object& core = asset_id_type()(db);
@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
trx.set_expiration(db.head_block_id()); trx.set_expiration(db.head_block_id());
//idump((moneyman)); //idump((moneyman));
trx.sign( delegate_priv_key ); trx.sign( init_account_priv_key );
const proposal_object& proposal = db.get<proposal_object>(PUSH_TX( db, trx ).operation_results.front().get<object_id_type>()); const proposal_object& proposal = db.get<proposal_object>(PUSH_TX( db, trx ).operation_results.front().get<object_id_type>());
BOOST_CHECK_EQUAL(proposal.required_active_approvals.size(), 1); BOOST_CHECK_EQUAL(proposal.required_active_approvals.size(), 1);
@ -355,14 +355,14 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
pup.active_approvals_to_add.insert(nathan.id); pup.active_approvals_to_add.insert(nathan.id);
trx.operations = {pup}; trx.operations = {pup};
trx.sign( genesis_key ); trx.sign( committee_key );
//Genesis may not add nathan's approval. //committee may not add nathan's approval.
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
pup.active_approvals_to_add.clear(); pup.active_approvals_to_add.clear();
pup.active_approvals_to_add.insert(account_id_type()); pup.active_approvals_to_add.insert(account_id_type());
trx.operations = {pup}; trx.operations = {pup};
trx.sign( genesis_key ); trx.sign( committee_key );
//Genesis has no stake in the transaction. //committee has no stake in the transaction.
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
trx.signatures.clear(); trx.signatures.clear();
@ -382,11 +382,11 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
} }
} }
/// Verify that genesis authority cannot be invoked in a normal transaction /// Verify that committee authority cannot be invoked in a normal transaction
BOOST_AUTO_TEST_CASE( genesis_authority ) BOOST_AUTO_TEST_CASE( committee_authority )
{ try { { try {
fc::ecc::private_key nathan_key = fc::ecc::private_key::generate(); fc::ecc::private_key nathan_key = fc::ecc::private_key::generate();
fc::ecc::private_key genesis_key = delegate_priv_key; fc::ecc::private_key committee_key = init_account_priv_key;
const account_object nathan = create_account("nathan", nathan_key.get_public_key()); const account_object nathan = create_account("nathan", nathan_key.get_public_key());
const auto& global_params = db.get_global_properties().parameters; const auto& global_params = db.get_global_properties().parameters;
@ -398,12 +398,12 @@ BOOST_AUTO_TEST_CASE( genesis_authority )
p.parameters.committee_proposal_review_period = fc::days(1).to_seconds(); p.parameters.committee_proposal_review_period = fc::days(1).to_seconds();
}); });
BOOST_TEST_MESSAGE( "transfering 100000 CORE to nathan, signing with genesis key" ); BOOST_TEST_MESSAGE( "transfering 100000 CORE to nathan, signing with committee key" );
transfer_operation top; transfer_operation top;
top.to = nathan.id; top.to = nathan.id;
top.amount = asset(100000); top.amount = asset(100000);
trx.operations.push_back(top); trx.operations.push_back(top);
sign(trx, genesis_key); sign(trx, committee_key);
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
auto sign = [&] { trx.signatures.clear(); trx.sign(nathan_key); }; auto sign = [&] { trx.signatures.clear(); trx.sign(nathan_key); };
@ -446,7 +446,7 @@ BOOST_AUTO_TEST_CASE( genesis_authority )
uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
uop.proposal = prop.id; uop.proposal = prop.id;
uop.key_approvals_to_add.emplace(genesis_key.get_public_key()); uop.key_approvals_to_add.emplace(committee_key.get_public_key());
/* /*
uop.key_approvals_to_add.emplace(1); uop.key_approvals_to_add.emplace(1);
uop.key_approvals_to_add.emplace(2); uop.key_approvals_to_add.emplace(2);
@ -456,16 +456,16 @@ BOOST_AUTO_TEST_CASE( genesis_authority )
uop.key_approvals_to_add.emplace(6); uop.key_approvals_to_add.emplace(6);
*/ */
trx.operations.push_back(uop); trx.operations.push_back(uop);
trx.sign(genesis_key); trx.sign(committee_key);
db.push_transaction(trx); db.push_transaction(trx);
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 0); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 0);
BOOST_CHECK(db.get<proposal_object>(prop.id).is_authorized_to_execute(db)); BOOST_CHECK(db.get<proposal_object>(prop.id).is_authorized_to_execute(db));
generate_blocks(*prop.review_period_time); generate_blocks(*prop.review_period_time);
uop.key_approvals_to_add.clear(); uop.key_approvals_to_add.clear();
uop.key_approvals_to_add.insert(genesis_key.get_public_key()); // was 7 uop.key_approvals_to_add.insert(committee_key.get_public_key()); // was 7
trx.operations.back() = uop; trx.operations.back() = uop;
trx.sign( genesis_key); trx.sign( committee_key);
// Should throw because the transaction is now in review. // Should throw because the transaction is now in review.
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
@ -473,18 +473,18 @@ BOOST_AUTO_TEST_CASE( genesis_authority )
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000);
} FC_LOG_AND_RETHROW() } } FC_LOG_AND_RETHROW() }
BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture ) BOOST_FIXTURE_TEST_CASE( fired_committee_members, database_fixture )
{ try { { try {
generate_block(); generate_block();
fc::ecc::private_key genesis_key = delegate_priv_key; fc::ecc::private_key committee_key = init_account_priv_key;
fc::ecc::private_key delegate_key = fc::ecc::private_key::generate(); fc::ecc::private_key committee_member_key = fc::ecc::private_key::generate();
//Meet nathan. He has a little money. //Meet nathan. He has a little money.
const account_object* nathan = &create_account("nathan"); const account_object* nathan = &create_account("nathan");
transfer(account_id_type()(db), *nathan, asset(5000)); transfer(account_id_type()(db), *nathan, asset(5000));
generate_block(); generate_block();
nathan = &get_account("nathan"); nathan = &get_account("nathan");
flat_set<vote_id_type> delegates; flat_set<vote_id_type> committee_members;
db.modify(db.get_global_properties(), [](global_property_object& p) { db.modify(db.get_global_properties(), [](global_property_object& p) {
// Turn the review period WAY down, so it doesn't take long to produce blocks to that point in simulated time. // Turn the review period WAY down, so it doesn't take long to produce blocks to that point in simulated time.
@ -493,13 +493,13 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
for( int i = 0; i < 15; ++i ) for( int i = 0; i < 15; ++i )
{ {
const auto& account = create_account("delegate" + fc::to_string(i+1), delegate_key.get_public_key()); const auto& account = create_account("committee-member" + fc::to_string(i+1), committee_member_key.get_public_key());
upgrade_to_lifetime_member(account); upgrade_to_lifetime_member(account);
delegates.insert(create_delegate(account).vote_id); committee_members.insert(create_committee_member(account).vote_id);
} }
//A proposal is created to give nathan lots more money. //A proposal is created to give nathan lots more money.
proposal_create_operation pop = proposal_create_operation::genesis_proposal(db.get_global_properties().parameters, db.head_block_time()); proposal_create_operation pop = proposal_create_operation::committee_proposal(db.get_global_properties().parameters, db.head_block_time());
pop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; pop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
pop.expiration_time = db.head_block_time() + *pop.review_period_seconds * 3; pop.expiration_time = db.head_block_time() + *pop.review_period_seconds * 3;
@ -512,11 +512,11 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
proposal_id_type pid = prop.id; proposal_id_type pid = prop.id;
BOOST_CHECK(!pid(db).is_authorized_to_execute(db)); BOOST_CHECK(!pid(db).is_authorized_to_execute(db));
//Genesis key approves of the proposal. //committee key approves of the proposal.
proposal_update_operation uop; proposal_update_operation uop;
uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
uop.proposal = pid; uop.proposal = pid;
uop.key_approvals_to_add.emplace(delegate_pub_key); uop.key_approvals_to_add.emplace(init_account_pub_key);
/* TODO: what should this really be? /* TODO: what should this really be?
uop.key_approvals_to_add.emplace(2); uop.key_approvals_to_add.emplace(2);
uop.key_approvals_to_add.emplace(3); uop.key_approvals_to_add.emplace(3);
@ -528,7 +528,7 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
uop.key_approvals_to_add.emplace(9); uop.key_approvals_to_add.emplace(9);
*/ */
trx.operations.back() = uop; trx.operations.back() = uop;
trx.sign(genesis_key); trx.sign(committee_key);
PUSH_TX( db, trx ); PUSH_TX( db, trx );
BOOST_CHECK(pid(db).is_authorized_to_execute(db)); BOOST_CHECK(pid(db).is_authorized_to_execute(db));
@ -545,11 +545,11 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000); BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000);
{ {
//Oh noes! Nathan votes for a whole new slate of delegates! //Oh noes! Nathan votes for a whole new slate of committee_members!
account_update_operation op; account_update_operation op;
op.account = nathan->id; op.account = nathan->id;
op.new_options = nathan->options; op.new_options = nathan->options;
op.new_options->votes = delegates; op.new_options->votes = committee_members;
trx.operations.push_back(op); trx.operations.push_back(op);
trx.set_expiration(db.head_block_time() + GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION); trx.set_expiration(db.head_block_time() + GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION);
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
@ -558,9 +558,9 @@ BOOST_FIXTURE_TEST_CASE( fired_delegates, database_fixture )
// still no money // still no money
BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000); BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000);
//Time passes... the set of active delegates gets updated. //Time passes... the set of active committee_members gets updated.
generate_blocks(maintenance_time); generate_blocks(maintenance_time);
//The proposal is no longer authorized, because the active delegates got changed. //The proposal is no longer authorized, because the active committee_members got changed.
BOOST_CHECK(!pid(db).is_authorized_to_execute(db)); BOOST_CHECK(!pid(db).is_authorized_to_execute(db));
// still no money // still no money
BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000); BOOST_CHECK_EQUAL(get_balance(*nathan, asset_id_type()(db)), 5000);
@ -882,17 +882,17 @@ BOOST_FIXTURE_TEST_CASE( max_authority_membership, database_fixture )
transaction tx; transaction tx;
processed_transaction ptx; processed_transaction ptx;
private_key_type genesis_key = delegate_priv_key; private_key_type committee_key = init_account_priv_key;
// Sam is the creator of accounts // Sam is the creator of accounts
private_key_type sam_key = generate_private_key("sam"); private_key_type sam_key = generate_private_key("sam");
account_object sam_account_object = create_account( "sam", sam_key ); account_object sam_account_object = create_account( "sam", sam_key );
upgrade_to_lifetime_member(sam_account_object); upgrade_to_lifetime_member(sam_account_object);
account_object genesis_account_object = genesis_account(db); account_object committee_account_object = committee_account(db);
const asset_object& core = asset_id_type()(db); const asset_object& core = asset_id_type()(db);
transfer(genesis_account_object, sam_account_object, core.amount(100000)); transfer(committee_account_object, sam_account_object, core.amount(100000));
// have Sam create some keys // have Sam create some keys
@ -968,13 +968,13 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
{ {
try try
{ {
private_key_type genesis_key = delegate_priv_key; private_key_type committee_key = init_account_priv_key;
// Sam is the creator of accounts // Sam is the creator of accounts
private_key_type alice_key = generate_private_key("alice"); private_key_type alice_key = generate_private_key("alice");
private_key_type bob_key = generate_private_key("bob"); private_key_type bob_key = generate_private_key("bob");
private_key_type charlie_key = generate_private_key("charlie"); private_key_type charlie_key = generate_private_key("charlie");
account_object genesis_account_object = genesis_account(db); account_object committee_account_object = committee_account(db);
account_object alice_account_object = create_account( "alice", alice_key ); account_object alice_account_object = create_account( "alice", alice_key );
account_object bob_account_object = create_account( "bob", bob_key ); account_object bob_account_object = create_account( "bob", bob_key );
account_object charlie_account_object = create_account( "charlie", charlie_key ); account_object charlie_account_object = create_account( "charlie", charlie_key );
@ -987,7 +987,7 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
// send from Sam -> Alice, signed by Sam // send from Sam -> Alice, signed by Sam
const asset_object& core = asset_id_type()(db); const asset_object& core = asset_id_type()(db);
transfer(genesis_account_object, alice_account_object, core.amount(100000)); transfer(committee_account_object, alice_account_object, core.amount(100000));
transfer_operation xfer_op; transfer_operation xfer_op;
xfer_op.from = alice_account_object.id; xfer_op.from = alice_account_object.id;
@ -1032,8 +1032,8 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
ACTORS((nathan)(vikram)); ACTORS((nathan)(vikram));
upgrade_to_lifetime_member(nathan_id); upgrade_to_lifetime_member(nathan_id);
upgrade_to_lifetime_member(vikram_id); upgrade_to_lifetime_member(vikram_id);
delegate_id_type nathan_delegate = create_delegate(nathan_id(db)).id; committee_member_id_type nathan_committee_member = create_committee_member(nathan_id(db)).id;
delegate_id_type vikram_delegate = create_delegate(vikram_id(db)).id; committee_member_id_type vikram_committee_member = create_committee_member(vikram_id(db)).id;
//wdump((db.get_balance(account_id_type(), asset_id_type()))); //wdump((db.get_balance(account_id_type(), asset_id_type())));
generate_block(); generate_block();
@ -1047,7 +1047,7 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
op.account = nathan_id; op.account = nathan_id;
op.new_options = nathan_id(db).options; op.new_options = nathan_id(db).options;
op.new_options->voting_account = vikram_id; op.new_options->voting_account = vikram_id;
op.new_options->votes = flat_set<vote_id_type>{nathan_delegate(db).vote_id}; op.new_options->votes = flat_set<vote_id_type>{nathan_committee_member(db).vote_id};
op.new_options->num_committee = 1; op.new_options->num_committee = 1;
trx.operations.push_back(op); trx.operations.push_back(op);
trx.sign(nathan_private_key); trx.sign(nathan_private_key);
@ -1058,7 +1058,7 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
account_update_operation op; account_update_operation op;
op.account = vikram_id; op.account = vikram_id;
op.new_options = vikram_id(db).options; op.new_options = vikram_id(db).options;
op.new_options->votes.insert(vikram_delegate(db).vote_id); op.new_options->votes.insert(vikram_committee_member(db).vote_id);
op.new_options->num_committee = 11; op.new_options->num_committee = 11;
trx.operations.push_back(op); trx.operations.push_back(op);
trx.sign(vikram_private_key); trx.sign(vikram_private_key);
@ -1073,12 +1073,12 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
} }
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time + GRAPHENE_DEFAULT_BLOCK_INTERVAL); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time + GRAPHENE_DEFAULT_BLOCK_INTERVAL);
BOOST_CHECK(std::find(db.get_global_properties().active_delegates.begin(), BOOST_CHECK(std::find(db.get_global_properties().active_committee_members.begin(),
db.get_global_properties().active_delegates.end(), db.get_global_properties().active_committee_members.end(),
nathan_delegate) == db.get_global_properties().active_delegates.end()); nathan_committee_member) == db.get_global_properties().active_committee_members.end());
BOOST_CHECK(std::find(db.get_global_properties().active_delegates.begin(), BOOST_CHECK(std::find(db.get_global_properties().active_committee_members.begin(),
db.get_global_properties().active_delegates.end(), db.get_global_properties().active_committee_members.end(),
vikram_delegate) != db.get_global_properties().active_delegates.end()); vikram_committee_member) != db.get_global_properties().active_committee_members.end());
} FC_LOG_AND_RETHROW() } } FC_LOG_AND_RETHROW() }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View file

@ -23,7 +23,6 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <graphene/chain/witness_scheduler_rng.hpp> #include <graphene/chain/witness_scheduler_rng.hpp>
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>

View file

@ -21,7 +21,7 @@
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/witness_schedule_object.hpp> #include <graphene/chain/witness_schedule_object.hpp>
@ -39,17 +39,17 @@ genesis_state_type make_genesis() {
genesis_state.initial_timestamp = time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP ); genesis_state.initial_timestamp = time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
genesis_state.initial_active_witnesses = 10; genesis_state.initial_active_witnesses = 10;
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i ) for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
{ {
auto name = "init"+fc::to_string(i); auto name = "init"+fc::to_string(i);
genesis_state.initial_accounts.emplace_back(name, genesis_state.initial_accounts.emplace_back(name,
delegate_priv_key.get_public_key(), init_account_priv_key.get_public_key(),
delegate_priv_key.get_public_key(), init_account_priv_key.get_public_key(),
true); true);
genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_committee_candidates.push_back({name});
genesis_state.initial_witness_candidates.push_back({name, delegate_priv_key.get_public_key()}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()});
} }
genesis_state.initial_parameters.current_fees->zero_all_fees(); genesis_state.initial_parameters.current_fees->zero_all_fees();
return genesis_state; return genesis_state;
@ -126,11 +126,11 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += GRAPHENE_DEFAULT_BLOCK_INTERVAL; now += GRAPHENE_DEFAULT_BLOCK_INTERVAL;
// TODO: Don't generate this here // TODO: Don't generate this here
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
{ {
database db; database db;
db.open(data_dir.path(), make_genesis ); db.open(data_dir.path(), make_genesis );
b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
for( uint32_t i = 1; i < 200; ++i ) for( uint32_t i = 1; i < 200; ++i )
{ {
@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += db.block_interval(); now += db.block_interval();
witness_id_type cur_witness = db.get_scheduled_witness(1).first; witness_id_type cur_witness = db.get_scheduled_witness(1).first;
BOOST_CHECK( cur_witness != prev_witness ); BOOST_CHECK( cur_witness != prev_witness );
b = db.generate_block(now, cur_witness, delegate_priv_key, database::skip_nothing); b = db.generate_block(now, cur_witness, init_account_priv_key, database::skip_nothing);
BOOST_CHECK( b.witness == cur_witness ); BOOST_CHECK( b.witness == cur_witness );
} }
db.close(); db.close();
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( generate_empty_blocks )
now += db.block_interval(); now += db.block_interval();
witness_id_type cur_witness = db.get_scheduled_witness(1).first; witness_id_type cur_witness = db.get_scheduled_witness(1).first;
BOOST_CHECK( cur_witness != prev_witness ); BOOST_CHECK( cur_witness != prev_witness );
b = db.generate_block(now, cur_witness, delegate_priv_key, database::skip_nothing); b = db.generate_block(now, cur_witness, init_account_priv_key, database::skip_nothing);
} }
BOOST_CHECK_EQUAL( db.head_block_num(), 400 ); BOOST_CHECK_EQUAL( db.head_block_num(), 400 );
} }
@ -174,11 +174,11 @@ BOOST_AUTO_TEST_CASE( undo_block )
db.open(data_dir.path(), make_genesis); db.open(data_dir.path(), make_genesis);
fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP ); fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
for( uint32_t i = 0; i < 5; ++i ) for( uint32_t i = 0; i < 5; ++i )
{ {
now += db.block_interval(); now += db.block_interval();
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing ); auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing );
} }
BOOST_CHECK( db.head_block_num() == 5 ); BOOST_CHECK( db.head_block_num() == 5 );
db.pop_block(); db.pop_block();
@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE( undo_block )
for( uint32_t i = 0; i < 5; ++i ) for( uint32_t i = 0; i < 5; ++i )
{ {
now += db.block_interval(); now += db.block_interval();
auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing ); auto b = db.generate_block( now, db.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing );
} }
BOOST_CHECK( db.head_block_num() == 7 ); BOOST_CHECK( db.head_block_num() == 7 );
} }
@ -215,11 +215,11 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
database db2; database db2;
db2.open(data_dir2.path(), make_genesis); db2.open(data_dir2.path(), make_genesis);
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
for( uint32_t i = 0; i < 10; ++i ) for( uint32_t i = 0; i < 10; ++i )
{ {
now += db1.block_interval(); now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
try { try {
PUSH_BLOCK( db2, b ); PUSH_BLOCK( db2, b );
} FC_CAPTURE_AND_RETHROW( ("db2") ); } FC_CAPTURE_AND_RETHROW( ("db2") );
@ -227,13 +227,13 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
for( uint32_t i = 10; i < 13; ++i ) for( uint32_t i = 10; i < 13; ++i )
{ {
now += db1.block_interval(); now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
} }
string db1_tip = db1.head_block_id().str(); string db1_tip = db1.head_block_id().str();
for( uint32_t i = 13; i < 16; ++i ) for( uint32_t i = 13; i < 16; ++i )
{ {
now += db2.block_interval(); now += db2.block_interval();
auto b = db2.generate_block(now, db2.get_scheduled_witness(db2.get_slot_at_time(now)).first, delegate_priv_key, database::skip_nothing); auto b = db2.generate_block(now, db2.get_scheduled_witness(db2.get_slot_at_time(now)).first, init_account_priv_key, database::skip_nothing);
// notify both databases of the new block. // notify both databases of the new block.
// only db2 should switch to the new fork, db1 should not // only db2 should switch to the new fork, db1 should not
PUSH_BLOCK( db1, b ); PUSH_BLOCK( db1, b );
@ -248,11 +248,11 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
BOOST_CHECK_EQUAL(db2.head_block_num(), 13); BOOST_CHECK_EQUAL(db2.head_block_num(), 13);
{ {
now += db2.block_interval(); now += db2.block_interval();
auto b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); auto b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
good_block = b; good_block = b;
b.transactions.emplace_back(signed_transaction()); b.transactions.emplace_back(signed_transaction());
b.transactions.back().operations.emplace_back(transfer_operation()); b.transactions.back().operations.emplace_back(transfer_operation());
b.sign(delegate_priv_key); b.sign(init_account_priv_key);
BOOST_CHECK_EQUAL(b.block_num(), 14); BOOST_CHECK_EQUAL(b.block_num(), 14);
GRAPHENE_CHECK_THROW(PUSH_BLOCK( db1, b ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_BLOCK( db1, b ), fc::exception);
} }
@ -278,8 +278,8 @@ BOOST_AUTO_TEST_CASE( undo_pending )
database db; database db;
db.open(data_dir.path(), make_genesis); db.open(data_dir.path(), make_genesis);
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key(); public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db.get_index(protocol_ids, account_object_type); const graphene::db::index& account_idx = db.get_index(protocol_ids, account_object_type);
transfer_operation t; transfer_operation t;
@ -292,7 +292,7 @@ BOOST_AUTO_TEST_CASE( undo_pending )
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
now += db.block_interval(); now += db.block_interval();
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, ~0); auto b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, ~0);
} }
signed_transaction trx; signed_transaction trx;
@ -301,13 +301,13 @@ BOOST_AUTO_TEST_CASE( undo_pending )
account_create_operation cop; account_create_operation cop;
cop.registrar = GRAPHENE_TEMP_ACCOUNT; cop.registrar = GRAPHENE_TEMP_ACCOUNT;
cop.name = "nathan"; cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1); cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop); trx.operations.push_back(cop);
//trx.sign( delegate_priv_key ); //trx.sign( init_account_priv_key );
PUSH_TX( db, trx ); PUSH_TX( db, trx );
now += db.block_interval(); now += db.block_interval();
auto b = db.generate_block(now, db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); auto b = db.generate_block(now, db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
BOOST_CHECK(nathan_id(db).name == "nathan"); BOOST_CHECK(nathan_id(db).name == "nathan");
@ -345,8 +345,8 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
db2.open(dir2.path(), make_genesis); db2.open(dir2.path(), make_genesis);
fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP ); fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key(); public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type); const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
signed_transaction trx; signed_transaction trx;
@ -355,23 +355,23 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
account_create_operation cop; account_create_operation cop;
cop.registrar = GRAPHENE_TEMP_ACCOUNT; cop.registrar = GRAPHENE_TEMP_ACCOUNT;
cop.name = "nathan"; cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1); cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop); trx.operations.push_back(cop);
PUSH_TX( db1, trx ); PUSH_TX( db1, trx );
auto aw = db1.get_global_properties().active_witnesses; auto aw = db1.get_global_properties().active_witnesses;
now += db1.block_interval(); now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); auto b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
BOOST_CHECK(nathan_id(db1).name == "nathan"); BOOST_CHECK(nathan_id(db1).name == "nathan");
now = fc::time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP ); now = fc::time_point_sec( GRAPHENE_TESTING_GENESIS_TIMESTAMP );
now += db2.block_interval(); now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b); db1.push_block(b);
aw = db2.get_global_properties().active_witnesses; aw = db2.get_global_properties().active_witnesses;
now += db2.block_interval(); now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b); db1.push_block(b);
GRAPHENE_CHECK_THROW(nathan_id(db1), fc::exception); GRAPHENE_CHECK_THROW(nathan_id(db1), fc::exception);
@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
aw = db2.get_global_properties().active_witnesses; aw = db2.get_global_properties().active_witnesses;
now += db2.block_interval(); now += db2.block_interval();
b = db2.generate_block(now, db2.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); b = db2.generate_block(now, db2.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
db1.push_block(b); db1.push_block(b);
BOOST_CHECK(nathan_id(db1).name == "nathan"); BOOST_CHECK(nathan_id(db1).name == "nathan");
@ -404,8 +404,8 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
auto skip_sigs = database::skip_transaction_signatures | database::skip_authority_check; auto skip_sigs = database::skip_transaction_signatures | database::skip_authority_check;
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key(); public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type); const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
signed_transaction trx; signed_transaction trx;
@ -413,9 +413,9 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
account_id_type nathan_id = account_idx.get_next_id(); account_id_type nathan_id = account_idx.get_next_id();
account_create_operation cop; account_create_operation cop;
cop.name = "nathan"; cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1); cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop); trx.operations.push_back(cop);
trx.sign( delegate_priv_key ); trx.sign( init_account_priv_key );
PUSH_TX( db1, trx, skip_sigs ); PUSH_TX( db1, trx, skip_sigs );
trx = decltype(trx)(); trx = decltype(trx)();
@ -424,13 +424,13 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
t.to = nathan_id; t.to = nathan_id;
t.amount = asset(500); t.amount = asset(500);
trx.operations.push_back(t); trx.operations.push_back(t);
trx.sign( delegate_priv_key ); trx.sign( init_account_priv_key );
PUSH_TX( db1, trx, skip_sigs ); PUSH_TX( db1, trx, skip_sigs );
GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception);
now += db1.block_interval(); now += db1.block_interval();
auto b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key, skip_sigs ); auto b = db1.generate_block( now, db1.get_scheduled_witness( 1 ).first, init_account_priv_key, skip_sigs );
PUSH_BLOCK( db2, b, skip_sigs ); PUSH_BLOCK( db2, b, skip_sigs );
GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception); GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception);
@ -456,12 +456,12 @@ BOOST_AUTO_TEST_CASE( tapos )
const account_object& init1 = *db1.get_index_type<account_index>().indices().get<by_name>().find("init1"); const account_object& init1 = *db1.get_index_type<account_index>().indices().get<by_name>().find("init1");
auto delegate_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
public_key_type delegate_pub_key = delegate_priv_key.get_public_key(); public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type); const graphene::db::index& account_idx = db1.get_index(protocol_ids, account_object_type);
now += db1.block_interval(); now += db1.block_interval();
auto b = db1.generate_block(now, db1.get_scheduled_witness( 1 ).first, delegate_priv_key, database::skip_nothing); auto b = db1.generate_block(now, db1.get_scheduled_witness( 1 ).first, init_account_priv_key, database::skip_nothing);
signed_transaction trx; signed_transaction trx;
//This transaction must be in the next block after its reference, or it is invalid. //This transaction must be in the next block after its reference, or it is invalid.
@ -471,24 +471,24 @@ BOOST_AUTO_TEST_CASE( tapos )
account_create_operation cop; account_create_operation cop;
cop.registrar = init1.id; cop.registrar = init1.id;
cop.name = "nathan"; cop.name = "nathan";
cop.owner = authority(1, delegate_pub_key, 1); cop.owner = authority(1, init_account_pub_key, 1);
trx.operations.push_back(cop); trx.operations.push_back(cop);
trx.sign(delegate_priv_key); trx.sign(init_account_priv_key);
db1.push_transaction(trx); db1.push_transaction(trx);
now += db1.block_interval(); now += db1.block_interval();
b = db1.generate_block(now, db1.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); b = db1.generate_block(now, db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
trx.clear(); trx.clear();
transfer_operation t; transfer_operation t;
t.to = nathan_id; t.to = nathan_id;
t.amount = asset(50); t.amount = asset(50);
trx.operations.push_back(t); trx.operations.push_back(t);
trx.sign(delegate_priv_key); trx.sign(init_account_priv_key);
//relative_expiration is 1, but ref block is 2 blocks old, so this should fail. //relative_expiration is 1, but ref block is 2 blocks old, so this should fail.
GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception); GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception);
trx.set_expiration(db1.head_block_id(), 2); trx.set_expiration(db1.head_block_id(), 2);
trx.signatures.clear(); trx.signatures.clear();
trx.sign(delegate_priv_key); trx.sign(init_account_priv_key);
db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check); db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check);
} catch (fc::exception& e) { } catch (fc::exception& e) {
edump((e.to_detail_string())); edump((e.to_detail_string()));
@ -507,12 +507,12 @@ BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture )
auto initial_properties = db.get_global_properties(); auto initial_properties = db.get_global_properties();
const account_object& nathan = create_account("nathan"); const account_object& nathan = create_account("nathan");
upgrade_to_lifetime_member(nathan); upgrade_to_lifetime_member(nathan);
const delegate_object nathans_delegate = create_delegate(nathan); const committee_member_object nathans_committee_member = create_committee_member(nathan);
{ {
account_update_operation op; account_update_operation op;
op.account = nathan.id; op.account = nathan.id;
op.new_options = nathan.options; op.new_options = nathan.options;
op.new_options->votes.insert(nathans_delegate.vote_id); op.new_options->votes.insert(nathans_committee_member.vote_id);
trx.operations.push_back(op); trx.operations.push_back(op);
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
trx.operations.clear(); trx.operations.clear();
@ -526,15 +526,15 @@ BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture )
db.head_block_time().sec_since_epoch() + db.get_global_properties().parameters.block_interval); db.head_block_time().sec_since_epoch() + db.get_global_properties().parameters.block_interval);
// shuffling is now handled by the witness_schedule_object. // shuffling is now handled by the witness_schedule_object.
BOOST_CHECK(db.get_global_properties().active_witnesses == initial_properties.active_witnesses); BOOST_CHECK(db.get_global_properties().active_witnesses == initial_properties.active_witnesses);
BOOST_CHECK(db.get_global_properties().active_delegates == initial_properties.active_delegates); BOOST_CHECK(db.get_global_properties().active_committee_members == initial_properties.active_committee_members);
generate_block(); generate_block();
auto new_properties = db.get_global_properties(); auto new_properties = db.get_global_properties();
BOOST_CHECK(new_properties.active_delegates != initial_properties.active_delegates); BOOST_CHECK(new_properties.active_committee_members != initial_properties.active_committee_members);
BOOST_CHECK(std::find(new_properties.active_delegates.begin(), BOOST_CHECK(std::find(new_properties.active_committee_members.begin(),
new_properties.active_delegates.end(), nathans_delegate.id) != new_properties.active_committee_members.end(), nathans_committee_member.id) !=
new_properties.active_delegates.end()); new_properties.active_committee_members.end());
BOOST_CHECK_EQUAL(db.get_dynamic_global_properties().next_maintenance_time.sec_since_epoch(), BOOST_CHECK_EQUAL(db.get_dynamic_global_properties().next_maintenance_time.sec_since_epoch(),
maintenence_time.sec_since_epoch() + new_properties.parameters.maintenance_interval); maintenence_time.sec_since_epoch() + new_properties.parameters.maintenance_interval);
maintenence_time = db.get_dynamic_global_properties().next_maintenance_time; maintenence_time = db.get_dynamic_global_properties().next_maintenance_time;
@ -555,9 +555,9 @@ BOOST_FIXTURE_TEST_CASE( limit_order_expiration, database_fixture )
auto* test = &create_bitasset("TEST"); auto* test = &create_bitasset("TEST");
auto* core = &asset_id_type()(db); auto* core = &asset_id_type()(db);
auto* nathan = &create_account("nathan"); auto* nathan = &create_account("nathan");
auto* genesis = &account_id_type()(db); auto* committee = &account_id_type()(db);
transfer(*genesis, *nathan, core->amount(50000)); transfer(*committee, *nathan, core->amount(50000));
BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 50000 ); BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 50000 );
@ -584,7 +584,7 @@ BOOST_FIXTURE_TEST_CASE( limit_order_expiration, database_fixture )
test = &get_asset("TEST"); test = &get_asset("TEST");
core = &asset_id_type()(db); core = &asset_id_type()(db);
nathan = &get_account("nathan"); nathan = &get_account("nathan");
genesis = &account_id_type()(db); committee = &account_id_type()(db);
BOOST_CHECK(db.find_object(id) == nullptr); BOOST_CHECK(db.find_object(id) == nullptr);
BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 50000 ); BOOST_CHECK_EQUAL( get_balance(*nathan, *core), 50000 );
@ -646,16 +646,16 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
BOOST_TEST_MESSAGE( "Creating a proposal to change the block_interval to 1 second" ); BOOST_TEST_MESSAGE( "Creating a proposal to change the block_interval to 1 second" );
{ {
proposal_create_operation cop = proposal_create_operation::genesis_proposal(db.get_global_properties().parameters, db.head_block_time()); proposal_create_operation cop = proposal_create_operation::committee_proposal(db.get_global_properties().parameters, db.head_block_time());
cop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; cop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
cop.expiration_time = db.head_block_time() + *cop.review_period_seconds + 10; cop.expiration_time = db.head_block_time() + *cop.review_period_seconds + 10;
delegate_update_global_parameters_operation uop; committee_member_update_global_parameters_operation uop;
uop.new_parameters.block_interval = 1; uop.new_parameters.block_interval = 1;
cop.proposed_ops.emplace_back(uop); cop.proposed_ops.emplace_back(uop);
trx.operations.push_back(cop); trx.operations.push_back(cop);
db.push_transaction(trx); db.push_transaction(trx);
} }
BOOST_TEST_MESSAGE( "Updating proposal by signing with the delegate private key" ); BOOST_TEST_MESSAGE( "Updating proposal by signing with the committee_member private key" );
{ {
proposal_update_operation uop; proposal_update_operation uop;
uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
@ -664,15 +664,15 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
get_account("init4").get_id(), get_account("init5").get_id(), get_account("init4").get_id(), get_account("init5").get_id(),
get_account("init6").get_id(), get_account("init7").get_id()}; get_account("init6").get_id(), get_account("init7").get_id()};
trx.operations.push_back(uop); trx.operations.push_back(uop);
trx.sign(delegate_priv_key); trx.sign(init_account_priv_key);
/* /*
trx.sign(get_account("init1").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init1").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init2").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init2").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init3").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init3").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init4").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init4").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init5").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init5").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init6").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init6").active.get_keys().front(),init_account_priv_key);
trx.sign(get_account("init7").active.get_keys().front(),delegate_priv_key); trx.sign(get_account("init7").active.get_keys().front(),init_account_priv_key);
*/ */
db.push_transaction(trx); db.push_transaction(trx);
BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db)); BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db));
@ -709,8 +709,8 @@ BOOST_FIXTURE_TEST_CASE( unimp_force_settlement, database_fixture )
BOOST_FAIL( "TODO" ); BOOST_FAIL( "TODO" );
/* /*
try { try {
auto private_key = delegate_priv_key; auto private_key = init_account_priv_key;
auto private_key = generate_private_key("genesis"); auto private_key = generate_private_key("committee");
>>>>>>> short_refactor >>>>>>> short_refactor
account_id_type nathan_id = create_account("nathan").get_id(); account_id_type nathan_id = create_account("nathan").get_id();
account_id_type shorter1_id = create_account("shorter1").get_id(); account_id_type shorter1_id = create_account("shorter1").get_id();
@ -840,7 +840,7 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
try try
{ {
uint32_t skip_flags = ( uint32_t skip_flags = (
database::skip_delegate_signature database::skip_witness_signature
| database::skip_transaction_signatures | database::skip_transaction_signatures
| database::skip_authority_check | database::skip_authority_check
); );
@ -848,7 +848,7 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
const asset_object& core = asset_id_type()(db); const asset_object& core = asset_id_type()(db);
// Sam is the creator of accounts // Sam is the creator of accounts
private_key_type genesis_key = delegate_priv_key; private_key_type committee_key = init_account_priv_key;
private_key_type sam_key = generate_private_key("sam"); private_key_type sam_key = generate_private_key("sam");
account_object sam_account_object = create_account("sam", sam_key); account_object sam_account_object = create_account("sam", sam_key);
@ -862,9 +862,9 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture )
transaction tx; transaction tx;
processed_transaction ptx; processed_transaction ptx;
account_object genesis_account_object = genesis_account(db); account_object committee_account_object = committee_account(db);
// transfer from genesis account to Sam account // transfer from committee account to Sam account
transfer(genesis_account_object, sam_account_object, core.amount(100000)); transfer(committee_account_object, sam_account_object, core.amount(100000));
generate_block(skip_flags); generate_block(skip_flags);
@ -893,7 +893,7 @@ BOOST_FIXTURE_TEST_CASE( witness_scheduler_missed_blocks, database_fixture )
}); });
near_schedule = db.get_near_witness_schedule(); near_schedule = db.get_near_witness_schedule();
generate_block(0, delegate_priv_key, 2); generate_block(0, init_account_priv_key, 2);
BOOST_CHECK(db.get_dynamic_global_properties().current_witness == near_schedule[2]); BOOST_CHECK(db.get_dynamic_global_properties().current_witness == near_schedule[2]);
near_schedule.erase(near_schedule.begin(), near_schedule.begin() + 3); near_schedule.erase(near_schedule.begin(), near_schedule.begin() + 3);

View file

@ -21,7 +21,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp> #include <graphene/chain/withdraw_permission_object.hpp>
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_test )
const auto& bitusd = create_bitasset("BITUSD"); const auto& bitusd = create_bitasset("BITUSD");
const auto& core = asset_id_type()(db); const auto& core = asset_id_type()(db);
transfer(genesis_account, dan_id, asset(10000000)); transfer(committee_account, dan_id, asset(10000000));
update_feed_producers( bitusd, {sam.id} ); update_feed_producers( bitusd, {sam.id} );
price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100);
@ -162,9 +162,9 @@ BOOST_AUTO_TEST_CASE( margin_call_limit_test )
int64_t init_balance(1000000); int64_t init_balance(1000000);
transfer(genesis_account, buyer_id, asset(init_balance)); transfer(committee_account, buyer_id, asset(init_balance));
transfer(genesis_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower_id, asset(init_balance));
transfer(genesis_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance));
update_feed_producers( bitusd, {feedproducer.id} ); update_feed_producers( bitusd, {feedproducer.id} );
price_feed current_feed; price_feed current_feed;
@ -221,9 +221,9 @@ BOOST_AUTO_TEST_CASE( black_swan )
int64_t init_balance(1000000); int64_t init_balance(1000000);
transfer(genesis_account, buyer_id, asset(init_balance)); transfer(committee_account, buyer_id, asset(init_balance));
transfer(genesis_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower_id, asset(init_balance));
transfer(genesis_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance));
update_feed_producers(bitusd, {feedproducer.id}); update_feed_producers(bitusd, {feedproducer.id});
price_feed current_feed; price_feed current_feed;
@ -267,9 +267,9 @@ BOOST_AUTO_TEST_CASE( prediction_market )
const auto& core = asset_id_type()(db); const auto& core = asset_id_type()(db);
int64_t init_balance(1000000); int64_t init_balance(1000000);
transfer(genesis_account, judge_id, asset(init_balance)); transfer(committee_account, judge_id, asset(init_balance));
transfer(genesis_account, dan_id, asset(init_balance)); transfer(committee_account, dan_id, asset(init_balance));
transfer(genesis_account, nathan_id, asset(init_balance)); transfer(committee_account, nathan_id, asset(init_balance));
BOOST_TEST_MESSAGE( "Require throw for mismatch collateral amounts" ); BOOST_TEST_MESSAGE( "Require throw for mismatch collateral amounts" );
GRAPHENE_REQUIRE_THROW( borrow( dan, pmark.amount(1000), asset(2000) ), fc::exception ); GRAPHENE_REQUIRE_THROW( borrow( dan, pmark.amount(1000), asset(2000) ), fc::exception );
@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE( create_account_test )
op.owner = auth_bak; op.owner = auth_bak;
trx.operations.back() = op; trx.operations.back() = op;
trx.sign( delegate_priv_key); trx.sign( init_account_priv_key);
trx.validate(); trx.validate();
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
@ -339,11 +339,11 @@ BOOST_AUTO_TEST_CASE( create_account_test )
BOOST_CHECK(nathan_account.name == "nathan"); BOOST_CHECK(nathan_account.name == "nathan");
BOOST_REQUIRE(nathan_account.owner.num_auths() == 1); BOOST_REQUIRE(nathan_account.owner.num_auths() == 1);
BOOST_CHECK(nathan_account.owner.key_auths.at(genesis_key) == 123); BOOST_CHECK(nathan_account.owner.key_auths.at(committee_key) == 123);
BOOST_REQUIRE(nathan_account.active.num_auths() == 1); BOOST_REQUIRE(nathan_account.active.num_auths() == 1);
BOOST_CHECK(nathan_account.active.key_auths.at(genesis_key) == 321); 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 == account_id_type());
BOOST_CHECK(nathan_account.options.memo_key == genesis_key); BOOST_CHECK(nathan_account.options.memo_key == committee_key);
const account_statistics_object& statistics = nathan_account.statistics(db); const account_statistics_object& statistics = nathan_account.statistics(db);
BOOST_CHECK(statistics.id.space() == implementation_ids); BOOST_CHECK(statistics.id.space() == implementation_ids);
@ -357,38 +357,36 @@ BOOST_AUTO_TEST_CASE( create_account_test )
BOOST_AUTO_TEST_CASE( update_account ) BOOST_AUTO_TEST_CASE( update_account )
{ {
try { try {
const account_object& nathan = create_account("nathan", delegate_pub_key); const account_object& nathan = create_account("nathan", init_account_pub_key);
const fc::ecc::private_key nathan_new_key = fc::ecc::private_key::generate(); const fc::ecc::private_key nathan_new_key = fc::ecc::private_key::generate();
const public_key_type key_id = nathan_new_key.get_public_key(); const public_key_type key_id = nathan_new_key.get_public_key();
const auto& active_delegates = db.get_global_properties().active_delegates; const auto& active_committee_members = db.get_global_properties().active_committee_members;
transfer(account_id_type()(db), nathan, asset(30000)); transfer(account_id_type()(db), nathan, asset(1000000000));
trx.operations.clear(); trx.operations.clear();
account_update_operation op; account_update_operation op;
op.account = nathan.id; op.account = nathan.id;
op.owner = authority(2, key_id, 1, delegate_pub_key, 1); op.owner = authority(2, key_id, 1, init_account_pub_key, 1);
op.active = authority(2, key_id, 1, delegate_pub_key, 1); op.active = authority(2, key_id, 1, init_account_pub_key, 1);
op.new_options = nathan.options; op.new_options = nathan.options;
op.new_options->votes = flat_set<vote_id_type>({active_delegates[0](db).vote_id, active_delegates[5](db).vote_id}); op.new_options->votes = flat_set<vote_id_type>({active_committee_members[0](db).vote_id, active_committee_members[5](db).vote_id});
op.new_options->num_committee = 2; op.new_options->num_committee = 2;
trx.operations.push_back(op); trx.operations.push_back(op);
BOOST_TEST_MESSAGE( "Updating account" ); BOOST_TEST_MESSAGE( "Updating account" );
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK(nathan.options.memo_key == delegate_pub_key); BOOST_CHECK(nathan.options.memo_key == init_account_pub_key);
BOOST_CHECK(nathan.active.weight_threshold == 2); BOOST_CHECK(nathan.active.weight_threshold == 2);
BOOST_CHECK(nathan.active.num_auths() == 2); BOOST_CHECK(nathan.active.num_auths() == 2);
BOOST_CHECK(nathan.active.key_auths.at(key_id) == 1); BOOST_CHECK(nathan.active.key_auths.at(key_id) == 1);
BOOST_CHECK(nathan.active.key_auths.at(delegate_pub_key) == 1); BOOST_CHECK(nathan.active.key_auths.at(init_account_pub_key) == 1);
BOOST_CHECK(nathan.owner.weight_threshold == 2); BOOST_CHECK(nathan.owner.weight_threshold == 2);
BOOST_CHECK(nathan.owner.num_auths() == 2); BOOST_CHECK(nathan.owner.num_auths() == 2);
BOOST_CHECK(nathan.owner.key_auths.at(key_id) == 1); BOOST_CHECK(nathan.owner.key_auths.at(key_id) == 1);
BOOST_CHECK(nathan.owner.key_auths.at(delegate_pub_key) == 1); BOOST_CHECK(nathan.owner.key_auths.at(init_account_pub_key) == 1);
BOOST_CHECK(nathan.options.votes.size() == 2); BOOST_CHECK(nathan.options.votes.size() == 2);
transfer(account_id_type()(db), nathan, asset(3000000));
enable_fees(); enable_fees();
{ {
account_upgrade_operation op; account_upgrade_operation op;
@ -411,12 +409,12 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset )
try { try {
INVOKE(create_account_test); INVOKE(create_account_test);
account_id_type genesis_account; account_id_type committee_account;
asset genesis_balance = db.get_balance(account_id_type(), asset_id_type()); asset committee_balance = db.get_balance(account_id_type(), asset_id_type());
const account_object& nathan_account = *db.get_index_type<account_index>().indices().get<by_name>().find("nathan"); const account_object& nathan_account = *db.get_index_type<account_index>().indices().get<by_name>().find("nathan");
transfer_operation top; transfer_operation top;
top.from = genesis_account; top.from = committee_account;
top.to = nathan_account.id; top.to = nathan_account.id;
top.amount = asset( 10000); top.amount = asset( 10000);
trx.operations.push_back(top); trx.operations.push_back(top);
@ -427,14 +425,14 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset )
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)), BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)),
(genesis_balance.amount - 10000 - fee.amount).value); (committee_balance.amount - 10000 - fee.amount).value);
genesis_balance = db.get_balance(account_id_type(), asset_id_type()); committee_balance = db.get_balance(account_id_type(), asset_id_type());
BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 10000); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 10000);
trx = signed_transaction(); trx = signed_transaction();
top.from = nathan_account.id; top.from = nathan_account.id;
top.to = genesis_account; top.to = committee_account;
top.amount = asset(2000); top.amount = asset(2000);
trx.operations.push_back(top); trx.operations.push_back(top);
@ -445,7 +443,7 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset )
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 8000 - fee.amount.value); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 8000 - fee.amount.value);
BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)), genesis_balance.amount.value + 2000); BOOST_CHECK_EQUAL(get_balance(account_id_type()(db), asset_id_type()(db)), committee_balance.amount.value + 2000);
} catch (fc::exception& e) { } catch (fc::exception& e) {
edump((e.to_detail_string())); edump((e.to_detail_string()));
@ -453,23 +451,23 @@ BOOST_AUTO_TEST_CASE( transfer_core_asset )
} }
} }
BOOST_AUTO_TEST_CASE( create_delegate ) BOOST_AUTO_TEST_CASE( create_committee_member )
{ {
try { try {
delegate_create_operation op; committee_member_create_operation op;
op.delegate_account = account_id_type(); op.committee_member_account = account_id_type();
op.fee = asset(); op.fee = asset();
trx.operations.push_back(op); trx.operations.push_back(op);
REQUIRE_THROW_WITH_VALUE(op, delegate_account, account_id_type(99999999)); REQUIRE_THROW_WITH_VALUE(op, committee_member_account, account_id_type(99999999));
REQUIRE_THROW_WITH_VALUE(op, fee, asset(-600)); REQUIRE_THROW_WITH_VALUE(op, fee, asset(-600));
trx.operations.back() = op; trx.operations.back() = op;
delegate_id_type delegate_id = db.get_index_type<primary_index<simple_index<delegate_object>>>().get_next_id(); committee_member_id_type committee_member_id = db.get_index_type<primary_index<simple_index<committee_member_object>>>().get_next_id();
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
const delegate_object& d = delegate_id(db); const committee_member_object& d = committee_member_id(db);
BOOST_CHECK(d.delegate_account == account_id_type()); BOOST_CHECK(d.committee_member_account == account_id_type());
} catch (fc::exception& e) { } catch (fc::exception& e) {
edump((e.to_detail_string())); edump((e.to_detail_string()));
throw; throw;
@ -700,22 +698,22 @@ BOOST_AUTO_TEST_CASE( transfer_uia )
const asset_object& uia = *db.get_index_type<asset_index>().indices().get<by_symbol>().find("TEST"); const asset_object& uia = *db.get_index_type<asset_index>().indices().get<by_symbol>().find("TEST");
const account_object& nathan = *db.get_index_type<account_index>().indices().get<by_name>().find("nathan"); const account_object& nathan = *db.get_index_type<account_index>().indices().get<by_name>().find("nathan");
const account_object& genesis = account_id_type()(db); const account_object& committee = account_id_type()(db);
BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000); BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000);
transfer_operation top; transfer_operation top;
top.from = nathan.id; top.from = nathan.id;
top.to = genesis.id; top.to = committee.id;
top.amount = uia.amount(5000); top.amount = uia.amount(5000);
trx.operations.push_back(top); trx.operations.push_back(top);
BOOST_TEST_MESSAGE( "Transfering 5000 TEST from nathan to genesis" ); BOOST_TEST_MESSAGE( "Transfering 5000 TEST from nathan to committee" );
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 5000); BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 5000);
BOOST_CHECK_EQUAL(get_balance(genesis, uia), 5000); BOOST_CHECK_EQUAL(get_balance(committee, uia), 5000);
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 10000); BOOST_CHECK_EQUAL(get_balance(nathan, uia), 10000000 - 10000);
BOOST_CHECK_EQUAL(get_balance(genesis, uia), 10000); BOOST_CHECK_EQUAL(get_balance(committee, uia), 10000);
} catch(fc::exception& e) { } catch(fc::exception& e) {
edump((e.to_detail_string())); edump((e.to_detail_string()));
throw; throw;
@ -732,7 +730,7 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new )
const account_object& buyer_account = create_account( "buyer" ); const account_object& buyer_account = create_account( "buyer" );
const account_object& seller_account = create_account( "seller" ); const account_object& seller_account = create_account( "seller" );
transfer( genesis_account(db), buyer_account, test_asset.amount( 10000 ) ); transfer( committee_account(db), buyer_account, test_asset.amount( 10000 ) );
transfer( nathan_account, seller_account, core_asset.amount(10000) ); transfer( nathan_account, seller_account, core_asset.amount(10000) );
BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 );
@ -772,7 +770,7 @@ BOOST_AUTO_TEST_CASE( create_buy_exact_match_uia )
const account_object& buyer_account = create_account( "buyer" ); const account_object& buyer_account = create_account( "buyer" );
const account_object& seller_account = create_account( "seller" ); const account_object& seller_account = create_account( "seller" );
transfer( genesis_account(db), seller_account, asset( 10000 ) ); transfer( committee_account(db), seller_account, asset( 10000 ) );
transfer( nathan_account, buyer_account, test_asset.amount(10000) ); transfer( nathan_account, buyer_account, test_asset.amount(10000) );
BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 );
@ -813,7 +811,7 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new_reverse )
const account_object& buyer_account = create_account( "buyer" ); const account_object& buyer_account = create_account( "buyer" );
const account_object& seller_account = create_account( "seller" ); const account_object& seller_account = create_account( "seller" );
transfer( genesis_account(db), seller_account, asset( 10000 ) ); transfer( committee_account(db), seller_account, asset( 10000 ) );
transfer( nathan_account, buyer_account, test_asset.amount(10000),test_asset.amount(0) ); transfer( nathan_account, buyer_account, test_asset.amount(10000),test_asset.amount(0) );
BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 );
@ -853,7 +851,7 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new_reverse_fract )
const account_object& buyer_account = create_account( "buyer" ); const account_object& buyer_account = create_account( "buyer" );
const account_object& seller_account = create_account( "seller" ); const account_object& seller_account = create_account( "seller" );
transfer( genesis_account(db), seller_account, asset( 30 ) ); transfer( committee_account(db), seller_account, asset( 30 ) );
transfer( nathan_account, buyer_account, test_asset.amount(10000),test_asset.amount(0) ); transfer( nathan_account, buyer_account, test_asset.amount(10000),test_asset.amount(0) );
BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 );
@ -898,15 +896,15 @@ BOOST_AUTO_TEST_CASE( uia_fees )
const asset_object& test_asset = get_asset("TEST"); const asset_object& test_asset = get_asset("TEST");
const asset_dynamic_data_object& asset_dynamic = test_asset.dynamic_asset_data_id(db); const asset_dynamic_data_object& asset_dynamic = test_asset.dynamic_asset_data_id(db);
const account_object& nathan_account = get_account("nathan"); const account_object& nathan_account = get_account("nathan");
const account_object& genesis_account = account_id_type()(db); const account_object& committee_account = account_id_type()(db);
fund_fee_pool(genesis_account, test_asset, 1000*CORE); fund_fee_pool(committee_account, test_asset, 1000*CORE);
BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE); BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE);
transfer_operation op; transfer_operation op;
op.fee = test_asset.amount(0); op.fee = test_asset.amount(0);
op.from = nathan_account.id; op.from = nathan_account.id;
op.to = genesis_account.id; op.to = committee_account.id;
op.amount = test_asset.amount(100); op.amount = test_asset.amount(100);
op.fee = db.current_fee_schedule().calculate_fee( op, test_asset.options.core_exchange_rate ); op.fee = db.current_fee_schedule().calculate_fee( op, test_asset.options.core_exchange_rate );
BOOST_CHECK(op.fee.asset_id == test_asset.id); BOOST_CHECK(op.fee.asset_id == test_asset.id);
@ -919,7 +917,7 @@ BOOST_AUTO_TEST_CASE( uia_fees )
BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset),
(old_balance - fee - test_asset.amount(100)).amount.value); (old_balance - fee - test_asset.amount(100)).amount.value);
BOOST_CHECK_EQUAL(get_balance(genesis_account, test_asset), 100); BOOST_CHECK_EQUAL(get_balance(committee_account, test_asset), 100);
BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount); BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount);
BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount); BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount);
@ -927,7 +925,7 @@ BOOST_AUTO_TEST_CASE( uia_fees )
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset),
(old_balance - fee - fee - test_asset.amount(200)).amount.value); (old_balance - fee - fee - test_asset.amount(200)).amount.value);
BOOST_CHECK_EQUAL(get_balance(genesis_account, test_asset), 200); BOOST_CHECK_EQUAL(get_balance(committee_account, test_asset), 200);
BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount + fee.amount); BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount + fee.amount);
BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount - core_fee.amount); BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount - core_fee.amount);
@ -936,7 +934,7 @@ BOOST_AUTO_TEST_CASE( uia_fees )
op.amount = asset(20); op.amount = asset(20);
BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 0); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 0);
transfer(genesis_account, nathan_account, asset(20)); transfer(committee_account, nathan_account, asset(20));
BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 20); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 20);
trx.operations.emplace_back(std::move(op)); trx.operations.emplace_back(std::move(op));
@ -945,7 +943,7 @@ BOOST_AUTO_TEST_CASE( uia_fees )
BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 0); BOOST_CHECK_EQUAL(get_balance(nathan_account, asset_id_type()(db)), 0);
BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset), BOOST_CHECK_EQUAL(get_balance(nathan_account, test_asset),
(old_balance - fee - fee - fee - test_asset.amount(200)).amount.value); (old_balance - fee - fee - fee - test_asset.amount(200)).amount.value);
BOOST_CHECK_EQUAL(get_balance(genesis_account, test_asset), 200); BOOST_CHECK_EQUAL(get_balance(committee_account, test_asset), 200);
BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount.value * 3); BOOST_CHECK(asset_dynamic.accumulated_fees == fee.amount.value * 3);
BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount.value * 3); BOOST_CHECK(asset_dynamic.fee_pool == 1000*CORE - core_fee.amount.value * 3);
} catch (fc::exception& e) { } catch (fc::exception& e) {
@ -960,7 +958,7 @@ BOOST_AUTO_TEST_CASE( cancel_limit_order_test )
const asset_object& test_asset = get_asset( "TEST" ); const asset_object& test_asset = get_asset( "TEST" );
const account_object& buyer_account = create_account( "buyer" ); const account_object& buyer_account = create_account( "buyer" );
transfer( genesis_account(db), buyer_account, asset( 10000 ) ); transfer( committee_account(db), buyer_account, asset( 10000 ) );
BOOST_CHECK_EQUAL( get_balance(buyer_account, asset_id_type()(db)), 10000 ); BOOST_CHECK_EQUAL( get_balance(buyer_account, asset_id_type()(db)), 10000 );
auto sell_order = create_sell_order( buyer_account, asset(1000), test_asset.amount(100+450*1) ); auto sell_order = create_sell_order( buyer_account, asset(1000), test_asset.amount(100+450*1) );
@ -976,7 +974,7 @@ BOOST_AUTO_TEST_CASE( cancel_limit_order_test )
} }
} }
BOOST_AUTO_TEST_CASE( delegate_feeds ) BOOST_AUTO_TEST_CASE( witness_feeds )
{ {
using namespace graphene::chain; using namespace graphene::chain;
try { try {
@ -1021,7 +1019,7 @@ BOOST_AUTO_TEST_CASE( delegate_feeds )
op.publisher = active_witnesses[2]; op.publisher = active_witnesses[2];
op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40)); op.feed.settlement_price = ~price(asset(GRAPHENE_BLOCKCHAIN_PRECISION),bit_usd.amount(40));
// But this delegate is an idiot. // But this witness is an idiot.
op.feed.maintenance_collateral_ratio = 1001; op.feed.maintenance_collateral_ratio = 1001;
trx.operations.back() = op; trx.operations.back() = op;
PUSH_TX( db, trx, ~0 ); PUSH_TX( db, trx, ~0 );
@ -1051,7 +1049,7 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero )
const account_object& core_seller = create_account( "shorter1" ); const account_object& core_seller = create_account( "shorter1" );
const account_object& core_buyer = get_account("nathan"); const account_object& core_buyer = get_account("nathan");
transfer( genesis_account(db), core_seller, asset( 100000000 ) ); transfer( committee_account(db), core_seller, asset( 100000000 ) );
BOOST_CHECK_EQUAL(get_balance(core_buyer, core), 0); BOOST_CHECK_EQUAL(get_balance(core_buyer, core), 0);
BOOST_CHECK_EQUAL(get_balance(core_buyer, test), 10000000); BOOST_CHECK_EQUAL(get_balance(core_buyer, test), 10000000);
@ -1109,7 +1107,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test )
generate_block(); generate_block();
// Make an account and upgrade it to prime, so that witnesses get some pay // Make an account and upgrade it to prime, so that witnesses get some pay
create_account("nathan", delegate_pub_key); create_account("nathan", init_account_pub_key);
transfer(account_id_type()(db), get_account("nathan"), asset(20000*CORE)); transfer(account_id_type()(db), get_account("nathan"), asset(20000*CORE));
transfer(account_id_type()(db), get_account("init3"), asset(20*CORE)); transfer(account_id_type()(db), get_account("init3"), asset(20*CORE));
generate_block(); generate_block();
@ -1149,7 +1147,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test )
trx.operations.push_back(uop); trx.operations.push_back(uop);
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
trx.validate(); trx.validate();
trx.sign(delegate_priv_key); trx.sign(init_account_priv_key);
db.push_transaction(trx); db.push_transaction(trx);
trx.clear(); trx.clear();
BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 20000*CORE - account_upgrade_operation::fee_parameters_type().membership_lifetime_fee );; BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 20000*CORE - account_upgrade_operation::fee_parameters_type().membership_lifetime_fee );;
@ -1336,7 +1334,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_create_test )
const account_object& alice_account = create_account("alice"); const account_object& alice_account = create_account("alice");
const account_object& bob_account = create_account("bob"); const account_object& bob_account = create_account("bob");
transfer(genesis_account(db), alice_account, core.amount(100000)); transfer(committee_account(db), alice_account, core.amount(100000));
op.creator = alice_account.get_id(); op.creator = alice_account.get_id();
op.owner = alice_account.get_id(); op.owner = alice_account.get_id();
@ -1385,7 +1383,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test )
const account_object& alice_account = create_account( "alice" ); const account_object& alice_account = create_account( "alice" );
const account_object& bob_account = create_account( "bob" ); const account_object& bob_account = create_account( "bob" );
transfer( genesis_account(db), alice_account, core.amount( 1000000 ) ); transfer( committee_account(db), alice_account, core.amount( 1000000 ) );
auto spin_vbo_clock = [&]( const vesting_balance_object& vbo, uint32_t dt_secs ) auto spin_vbo_clock = [&]( const vesting_balance_object& vbo, uint32_t dt_secs )
{ {
@ -1424,7 +1422,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test )
auto top_up = [&]() auto top_up = [&]()
{ {
trx.clear(); trx.clear();
transfer( genesis_account(db), transfer( committee_account(db),
alice_account, alice_account,
core.amount( 1000000 - db.get_balance( alice_account, core ).amount ) core.amount( 1000000 - db.get_balance( alice_account, core ).amount )
); );

View file

@ -25,7 +25,7 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/balance_object.hpp> #include <graphene/chain/balance_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/worker_evaluator.hpp> #include <graphene/chain/worker_evaluator.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
@ -413,7 +413,7 @@ BOOST_AUTO_TEST_CASE( witness_create )
trx.clear(); trx.clear();
witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key).id; witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key).id;
// Give nathan some voting stake // Give nathan some voting stake
transfer(genesis_account, nathan_id, asset(10000000)); transfer(committee_account, nathan_id, asset(10000000));
generate_block(); generate_block();
trx.set_expiration(db.head_block_id()); trx.set_expiration(db.head_block_id());
@ -488,9 +488,9 @@ BOOST_AUTO_TEST_CASE( global_settle_test )
feed.maximum_short_squeeze_ratio = 150 * GRAPHENE_COLLATERAL_RATIO_DENOM / 100; feed.maximum_short_squeeze_ratio = 150 * GRAPHENE_COLLATERAL_RATIO_DENOM / 100;
publish_feed( bit_usd_id(db), nathan, feed ); publish_feed( bit_usd_id(db), nathan, feed );
transfer(genesis_account, ben_id, asset(10000)); transfer(committee_account, ben_id, asset(10000));
transfer(genesis_account, valentine_id, asset(10000)); transfer(committee_account, valentine_id, asset(10000));
transfer(genesis_account, dan_id, asset(10000)); transfer(committee_account, dan_id, asset(10000));
borrow(ben, asset(1000, bit_usd_id), asset(1000)); borrow(ben, asset(1000, bit_usd_id), asset(1000));
BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 1000); BOOST_CHECK_EQUAL(get_balance(ben_id, bit_usd_id), 1000);
BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000); BOOST_CHECK_EQUAL(get_balance(ben_id, asset_id_type()), 9000);
@ -597,7 +597,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test )
INVOKE(worker_create_test); INVOKE(worker_create_test);
GET_ACTOR(nathan); GET_ACTOR(nathan);
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
transfer(genesis_account, nathan_id, asset(100000)); transfer(committee_account, nathan_id, asset(100000));
{ {
account_update_operation op; account_update_operation op;
@ -710,7 +710,7 @@ BOOST_AUTO_TEST_CASE( refund_worker_test )
BOOST_CHECK(worker.vote_for.type() == vote_id_type::worker); BOOST_CHECK(worker.vote_for.type() == vote_id_type::worker);
BOOST_CHECK(worker.vote_against.type() == vote_id_type::worker); BOOST_CHECK(worker.vote_against.type() == vote_id_type::worker);
transfer(genesis_account, nathan_id, asset(100000)); transfer(committee_account, nathan_id, asset(100000));
{ {
account_update_operation op; account_update_operation op;
@ -783,7 +783,7 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
BOOST_CHECK(worker.vote_for.type() == vote_id_type::worker); BOOST_CHECK(worker.vote_for.type() == vote_id_type::worker);
BOOST_CHECK(worker.vote_against.type() == vote_id_type::worker); BOOST_CHECK(worker.vote_against.type() == vote_id_type::worker);
transfer(genesis_account, nathan_id, asset(100000)); transfer(committee_account, nathan_id, asset(100000));
{ {
account_update_operation op; account_update_operation op;
@ -826,8 +826,8 @@ BOOST_AUTO_TEST_CASE( unimp_force_settlement_unavailable )
BOOST_FAIL( "TODO - Reimplement this" ); BOOST_FAIL( "TODO - Reimplement this" );
/* /*
try { try {
auto private_key = delegate_priv_key; auto private_key = init_account_priv_key;
auto private_key = generate_private_key("genesis"); auto private_key = generate_private_key("committee");
>>>>>>> short_refactor >>>>>>> short_refactor
account_id_type nathan_id = create_account("nathan").get_id(); account_id_type nathan_id = create_account("nathan").get_id();
account_id_type shorter1_id = create_account("shorter1").get_id(); account_id_type shorter1_id = create_account("shorter1").get_id();
@ -1026,7 +1026,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
BOOST_CHECK(db.find_object(balance_id_type(1)) != nullptr); BOOST_CHECK(db.find_object(balance_id_type(1)) != nullptr);
auto slot = db.get_slot_at_time(starting_time); auto slot = db.get_slot_at_time(starting_time);
db.generate_block(starting_time, db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing); db.generate_block(starting_time, db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id()); trx.set_expiration(db.head_block_id());
const balance_object& vesting_balance_1 = balance_id_type(2)(db); const balance_object& vesting_balance_1 = balance_id_type(2)(db);
@ -1077,9 +1077,9 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
// Attempting to claim twice within a day // Attempting to claim twice within a day
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often); GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
slot = db.get_slot_at_time(vesting_balance_1.vesting_policy->begin_timestamp + 60); slot = db.get_slot_at_time(vesting_balance_1.vesting_policy->begin_timestamp + 60);
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing); db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id()); trx.set_expiration(db.head_block_id());
op.balance_to_claim = vesting_balance_1.id; op.balance_to_claim = vesting_balance_1.id;
@ -1103,9 +1103,9 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
// Attempting to claim twice within a day // Attempting to claim twice within a day
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often); GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, delegate_priv_key, database::skip_nothing); db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
slot = db.get_slot_at_time(db.head_block_time() + fc::days(1)); slot = db.get_slot_at_time(db.head_block_time() + fc::days(1));
db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, delegate_priv_key, database::skip_nothing); db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot).first, init_account_priv_key, database::skip_nothing);
trx.set_expiration(db.head_block_id()); trx.set_expiration(db.head_block_id());
op.total_claimed = vesting_balance_2.balance; op.total_claimed = vesting_balance_2.balance;

View file

@ -23,7 +23,6 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/delegate_object.hpp>
#include <fc/crypto/digest.hpp> #include <fc/crypto/digest.hpp>
@ -259,7 +258,7 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia )
BOOST_CHECK(!nathan.is_authorized_asset(advanced)); BOOST_CHECK(!nathan.is_authorized_asset(advanced));
GRAPHENE_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception); GRAPHENE_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception);
//Remove nathan from genesis' whitelist, add him to dan's. This should not authorize him to hold ADVANCED. //Remove nathan from committee's whitelist, add him to dan's. This should not authorize him to hold ADVANCED.
wop.authorizing_account = account_id_type(); wop.authorizing_account = account_id_type();
wop.account_to_list = nathan.id; wop.account_to_list = nathan.id;
wop.new_listing = account_whitelist_operation::no_listing; wop.new_listing = account_whitelist_operation::no_listing;