31 #include <graphene/chain/hardfork.hpp> 51 namespace graphene {
namespace chain {
54 vector<std::reference_wrapper<const typename Index::object_type>> database::sort_votable_objects(
size_t count)
const 56 using ObjectType =
typename Index::object_type;
57 const auto& all_objects = get_index_type<Index>().indices();
58 count = std::min(count, all_objects.size());
59 vector<std::reference_wrapper<const ObjectType>> refs;
60 refs.reserve(all_objects.size());
62 std::back_inserter(refs),
63 [](
const ObjectType& o) {
return std::cref(o); });
64 std::partial_sort(refs.begin(), refs.begin() + count, refs.end(),
65 [
this](
const ObjectType& a,
const ObjectType& b)->
bool {
66 share_type oa_vote = _vote_tally_buffer[a.vote_id];
67 share_type ob_vote = _vote_tally_buffer[b.vote_id];
68 if( oa_vote != ob_vote )
69 return oa_vote > ob_vote;
70 return a.vote_id < b.vote_id;
73 refs.resize(count, refs.front());
78 void database::perform_account_maintenance(Type tally_helper)
80 const auto& bal_idx = get_index_type< account_balance_index >().indices().get< by_maintenance_flag >();
81 if( bal_idx.begin() != bal_idx.end() )
83 auto bal_itr = bal_idx.rbegin();
84 while( bal_itr->maintenance_flag )
86 const account_balance_object& bal_obj = *bal_itr;
89 aso.core_in_balance = bal_obj.balance;
92 modify( bal_obj, []( account_balance_object& abo ) {
93 abo.maintenance_flag =
false;
96 bal_itr = bal_idx.rbegin();
100 const auto& stats_idx = get_index_type< account_stats_index >().indices().get< by_maintenance_seq >();
101 auto stats_itr = stats_idx.lower_bound(
true );
103 while( stats_itr != stats_idx.end() )
105 const account_statistics_object& acc_stat = *stats_itr;
106 const account_object& acc_obj = acc_stat.owner( *
this );
109 if( acc_stat.has_some_core_voting() )
110 tally_helper( acc_obj, acc_stat );
112 if( acc_stat.has_pending_fees() )
113 acc_stat.process_fees( acc_obj, *
this );
127 : pay(pay), db(db) {}
133 worker.pay_worker(pay, db);
137 void database::update_worker_votes()
139 const auto& idx = get_index_type<worker_index>().indices().get<by_account>();
140 auto itr = idx.begin();
141 auto itr_end = idx.end();
143 while( itr != itr_end )
154 void database::pay_workers(
share_type& budget )
158 vector<std::reference_wrapper<const worker_object>> active_workers;
160 get_index_type<worker_index>().inspect_all_objects([head_time, &active_workers](
const object& o) {
163 active_workers.emplace_back(w);
171 if( wa_vote != wb_vote )
172 return wa_vote > wb_vote;
173 return wa.
id < wb.id;
177 const auto passed_time_ms = head_time - last_budget_time;
178 const auto passed_time_count = passed_time_ms.count();
180 for( uint32_t i = 0; i < active_workers.size() && budget > 0; ++i )
188 fc::uint128_t pay = requested_pay.
value;
189 pay *= passed_time_count;
191 requested_pay =
static_cast<uint64_t
>(pay);
193 share_type actual_pay = std::min(budget, requested_pay);
199 budget -= actual_pay;
203 void database::update_active_witnesses()
205 assert( !_witness_count_histogram_buffer.empty() );
206 constexpr
size_t two = 2;
208 share_type stake_target = (_total_voting_stake[vid_witness]-_witness_count_histogram_buffer[0]) / two;
215 size_t witness_count = 0;
216 if( stake_target > 0 )
218 while( (witness_count < _witness_count_histogram_buffer.size() - 1)
219 && (stake_tally <= stake_target) )
221 stake_tally += _witness_count_histogram_buffer[++witness_count];
227 witness_count = std::max( ( witness_count * two ) + 1,
229 auto wits = sort_votable_objects<witness_index>( witness_count );
233 auto update_witness_total_votes = [
this](
const witness_object& wit ) {
240 if( _track_standby_votes )
242 const auto& all_witnesses = get_index_type<witness_index>().indices();
245 update_witness_total_votes( wit );
252 update_witness_total_votes( wit );
261 uint64_t total_votes = 0;
262 map<account_id_type, uint64_t> weights;
268 weights.emplace(wit.witness_account, _vote_tally_buffer[wit.vote_id]);
269 total_votes += _vote_tally_buffer[wit.vote_id];
274 uint64_t votes_msb = boost::multiprecision::detail::find_msb(total_votes);
275 constexpr uint8_t bits_to_keep_minus_one = 15;
276 uint64_t bits_to_drop = (votes_msb > bits_to_keep_minus_one) ? (votes_msb - bits_to_keep_minus_one) : 0;
277 for(
const auto& weight : weights )
280 uint16_t votes = std::max((uint16_t)(weight.second >> bits_to_drop), uint16_t(1) );
292 vc.
add( wit.witness_account, _vote_tally_buffer[wit.vote_id] );
310 void database::update_active_committee_members()
312 assert( !_committee_count_histogram_buffer.empty() );
313 constexpr
size_t two = 2;
315 share_type stake_target = (_total_voting_stake[vid_committee]-_committee_count_histogram_buffer[0]) / two;
320 size_t committee_member_count = 0;
321 if( stake_target > 0 )
323 while( (committee_member_count < _committee_count_histogram_buffer.size() - 1)
324 && (stake_tally <= stake_target.
value) )
326 stake_tally += _committee_count_histogram_buffer[++committee_member_count];
332 committee_member_count = std::max( ( committee_member_count * two ) + 1,
334 auto committee_members = sort_votable_objects<committee_member_index>( committee_member_count );
343 if( _track_standby_votes )
345 const auto& all_committee_members = get_index_type<committee_member_index>().indices();
348 update_committee_member_total_votes( cm );
355 update_committee_member_total_votes( cm );
360 if( !committee_members.empty() )
367 uint64_t total_votes = 0;
368 map<account_id_type, uint64_t> weights;
374 weights.emplace( cm.committee_member_account, _vote_tally_buffer[cm.vote_id] );
375 total_votes += _vote_tally_buffer[cm.vote_id];
381 uint64_t votes_msb = boost::multiprecision::detail::find_msb(total_votes);
382 constexpr uint8_t bits_to_keep_minus_one = 15;
383 uint64_t bits_to_drop = (votes_msb > bits_to_keep_minus_one) ? (votes_msb - bits_to_keep_minus_one) : 0;
384 for(
const auto& weight : weights )
387 uint16_t votes = std::max((uint16_t)(weight.second >> bits_to_drop), uint16_t(1) );
399 vc.
add( cm.committee_member_account, _vote_tally_buffer[cm.vote_id] );
411 std::transform(committee_members.begin(), committee_members.end(),
449 fc::uint128_t budget_u128 = reserve.
value;
450 budget_u128 *= uint64_t(dt);
457 if( budget_u128 < static_cast<fc::uint128_t>(reserve.
value) )
468 void database::process_budget()
483 assert( time_to_maint > 0 );
497 initialize_budget_record( now, rec );
502 witness_budget = std::min(witness_budget, available_funds);
504 available_funds -= witness_budget;
507 worker_budget_u128 *= uint64_t(time_to_maint);
508 constexpr uint64_t seconds_per_day = 86400;
509 worker_budget_u128 /= seconds_per_day;
512 if( worker_budget_u128 >= static_cast<fc::uint128_t>(available_funds.
value) )
513 worker_budget = available_funds;
515 worker_budget =
static_cast<uint64_t
>(worker_budget_u128);
517 available_funds -= worker_budget;
519 share_type leftover_worker_funds = worker_budget;
520 pay_workers(leftover_worker_funds);
522 available_funds += leftover_worker_funds;
532 ,&witness_budget,&worker_budget,&leftover_worker_funds,&dpo
541 - leftover_worker_funds
570 template<
typename Visitor >
597 const top_holders_special_authority& tha = auth.get< top_holders_special_authority >();
599 const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
600 uint8_t num_needed = tha.num_top_holders;
601 if( 0 == num_needed )
605 const auto range = bal_idx.equal_range( boost::make_tuple( tha.asset ) );
606 for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) )
608 assert( bal.asset_type == tha.asset );
609 if( bal.owner == acct.id )
611 vc.add( bal.owner, bal.balance.value );
613 if( 0 == num_needed )
619 vc.finish( is_owner ? a.owner : a.active );
621 a.top_n_control_flags |= (is_owner ? account_object::top_n_control_owner
622 : account_object::top_n_control_active);
631 uint16_t network_pct,
632 uint16_t designated_asset_buyback_pct,
633 uint16_t designated_asset_issuer_pct
636 FC_ASSERT( ( uint32_t(network_pct) + designated_asset_buyback_pct ) + designated_asset_issuer_pct
646 ilog(
"${n} core given to network at block ${b} due to non-configured FBA",
660 buyback_amount_128 *= designated_asset_buyback_pct;
662 share_type buyback_amount =
static_cast<uint64_t
>(buyback_amount_128);
665 issuer_amount_128 *= designated_asset_issuer_pct;
667 share_type issuer_amount =
static_cast<uint64_t
>(issuer_amount_128);
676 if( network_amount != 0 )
687 vop.
amount = buyback_amount;
696 vop.
amount = issuer_amount;
711 constexpr uint16_t twenty = 20;
713 constexpr uint16_t sixty = 60;
724 .get_secondary_index< balances_by_account_index >();
728 const asset_object& asset_to_buy = bbo.asset_to_buy(db);
733 if( !buyback_account.allowed_assets.valid() )
735 wlog(
"skipping buyback account ${b} at block ${n} because allowed_assets does not exist",
740 for(
const auto& entry : bal_idx.get_account_balances( buyback_account.get_id() ) )
742 const auto* it = entry.second;
743 asset_id_type asset_to_sell = it->asset_type;
745 if( asset_to_sell == asset_to_buy.
id )
747 if( amount_to_sell == 0 )
749 if( buyback_account.allowed_assets->find( asset_to_sell ) == buyback_account.allowed_assets->end() )
751 wlog(
"buyback account ${b} not selling disallowed holdings of asset ${a} at block ${n}",
752 (
"b", buyback_account)(
"a", asset_to_sell)(
"n", db.
head_block_num()) );
762 create_vop.
fee =
asset( 0, asset_id_type() );
763 create_vop.
seller = buyback_account.id;
771 if( db.
find( order_id ) != nullptr )
774 cancel_vop.
fee =
asset( 0, asset_id_type() );
775 cancel_vop.
order = order_id;
785 wlog(
"Skipping buyback processing selling ${as} for ${ab} for buyback account ${b} at block ${n}; " 786 "exception was ${e}",
787 (
"as", asset_to_sell)(
"ab", asset_to_buy)(
"b", buyback_account)
807 if( acct.is_annual_member( now ) )
810 upgrade_vop.
fee =
asset( 0, asset_id_type() );
819 wlog(
"Skipping annual member deprecate processing for account ${a} (${an}) at block ${n}; exception was ${e}",
832 asset_id_type to_revive_id = bad.
asset_id;
838 _cancel_bids_and_revive_mpa( to_revive, bad );
844 const auto& bid_idx = get_index_type< collateral_bid_index >().indices().get<by_price>();
845 const auto start = bid_idx.lower_bound( to_revive_id );
846 auto end = bid_idx.upper_bound( to_revive_id );
862 covered += debt_in_bid.
amount;
880 if( debt >= to_cover )
883 collateral = remaining_fund;
886 remaining_fund -= collateral;
892 _cancel_bids_and_revive_mpa( to_revive, bad );
900 wlog(
"Updating all call orders for hardfork core-343 at block ${n}", (
"n",db.
head_block_num()) );
901 asset_id_type current_asset;
906 if( current_asset != call_obj.debt_type() )
908 current_asset = call_obj.debt_type();
909 abd = ¤t_asset(db).bitasset_data(db);
918 wlog(
"Done updating all call orders for hardfork core-343 at block ${n}", (
"n",db.
head_block_num()) );
941 auto itr = asset_idx.lower_bound(
true );
942 auto itr_end = asset_idx.end();
943 while( itr != itr_end )
953 void database::process_bitassets()
957 bool after_hf_core_518 = ( head_time >= HARDFORK_CORE_518_TIME );
959 const auto& update_bitasset = [
this,&head_time,head_epoch_seconds,after_hf_core_518]
962 o.force_settled_volume = 0;
965 if( after_hf_core_518 && o.options.feed_lifetime_sec < head_epoch_seconds
969 auto itr = o.feeds.rbegin();
970 auto end = o.feeds.rend();
973 auto feed_time = itr->second.first;
974 std::advance( itr, 1 );
975 if( feed_time < calculated )
976 o.feeds.erase( itr.base() );
984 for(
const auto& d : get_index_type<asset_bitasset_data_index>().indices() )
986 modify( d, update_bitasset );
987 if( d.has_settlement() )
1002 auto asset_end = asset_idx.end();
1003 for(
auto asset_itr = asset_idx.lower_bound(
true); asset_itr != asset_end; ++asset_itr )
1005 const auto& current_asset = *asset_itr;
1010 wlog(
"Adjusting max_supply of ${asset} because current_supply (${current_supply}) is greater than ${old}.",
1011 (
"asset", current_asset.symbol)
1012 (
"current_supply", current_supply.
value)
1013 (
"old", max_supply));
1027 const balance_object* bal = db.
find( balance_id_type( HARDFORK_CORE_2103_BALANCE_ID ) );
1038 static void update_bitasset_current_feeds(
database& db)
1067 auto asset_end = asset_idx.end();
1068 for(
auto asset_itr = asset_idx.lower_bound(
true); asset_itr != asset_end; ++asset_itr )
1070 const auto& current_asset = *asset_itr;
1075 bool is_witness_or_committee_fed =
false;
1077 is_witness_or_committee_fed =
true;
1081 auto itr = bitasset_data.
feeds.begin();
1082 while( itr != bitasset_data.
feeds.end() )
1086 && ( is_witness_or_committee_fed || itr->second.second.settlement_price !=
price() ) )
1090 if( is_witness_or_committee_fed )
1093 itr = obj.
feeds.erase(itr);
1098 obj.
feeds[itr->first].second.settlement_price =
price();
1135 if( ticket_obj.current_type !=
liquid )
1150 auto bid_itr = bid_idx.begin();
1151 auto bid_end = bid_idx.end();
1153 asset_id_type current_asset_id;
1154 bool can_bid_collateral =
true;
1156 while( bid_itr != bid_end )
1163 can_bid_collateral = current_asset_id(db).can_bid_collateral();
1165 if( !can_bid_collateral )
1182 : full_power_seconds(f), recalc_steps(d), seconds_per_step(s)
1184 total_recalc_seconds = ( recalc_steps - 1 ) * seconds_per_step;
1185 power_percents_to_subtract.reserve( recalc_steps - 1 );
1186 for( uint32_t i = 1; i < recalc_steps; ++i )
1188 power_percents_to_subtract.push_back( (uint16_t)( (
GRAPHENE_100_PERCENT * i ) / recalc_steps ) );
1193 return { now - full_power_seconds, now - full_power_seconds - total_recalc_seconds };
1216 uint32_t steps_to_subtract_minus_1 = diff / seconds_per_step;
1217 fc::uint128_t stake_to_subtract( stake );
1218 stake_to_subtract *= power_percents_to_subtract[steps_to_subtract_minus_1];
1220 return stake -
static_cast<uint64_t
>(stake_to_subtract);
1246 void database::perform_chain_maintenance(
const signed_block& next_block )
1255 struct vote_tally_helper {
1260 const bool hf2103_passed;
1261 const bool hf2262_passed;
1262 const bool pob_activated;
1263 const size_t two = 2;
1273 explicit vote_tally_helper(
database& db )
1275 now( d.
head_block_time() ), hf2103_passed( HARDFORK_CORE_2103_PASSED( now ) ),
1276 hf2262_passed( HARDFORK_CORE_2262_PASSED( now ) ),
1282 d._total_voting_stake[vid_committee] = 0;
1283 d._total_voting_stake[vid_witness] = 0;
1305 const account_object& opinion_account = ( directly_voting ? stake_account
1308 std::array<uint64_t,3> voting_stake;
1309 uint64_t num_committee_voting_stake;
1311 voting_stake[vid_worker] += ( !hf2262_passed && stake_account.
cashback_vb.
valid() ) ?
1312 (*stake_account.
cashback_vb)(d).balance.amount.value : 0;
1316 uint64_t vp_all = 0;
1317 uint64_t vp_active = 0;
1319 uint64_t vp_committee = 0;
1320 uint64_t vp_witness = 0;
1321 uint64_t vp_worker = 0;
1328 if( 0 == pob_amount )
1330 voting_stake[vid_worker] += pol_value;
1332 else if( 0 == pol_amount )
1334 if( pob_amount <= voting_stake[vid_worker] )
1336 voting_stake[vid_worker] += ( pob_value - pob_amount );
1340 auto base_value = (
static_cast<fc::uint128_t
>( voting_stake[vid_worker] ) * pob_value )
1342 voting_stake[vid_worker] =
static_cast<uint64_t
>( base_value );
1345 else if( pob_amount <= pol_amount )
1347 auto base_value = (
static_cast<fc::uint128_t
>( pob_value ) * pol_value ) / pol_amount;
1348 auto diff_value = (
static_cast<fc::uint128_t
>( pob_amount ) * pol_value ) / pol_amount;
1349 base_value += ( pol_value - diff_value );
1350 voting_stake[vid_worker] +=
static_cast<uint64_t
>( base_value );
1354 auto base_value = (
static_cast<fc::uint128_t
>( pol_value ) * pob_value ) / pob_amount;
1355 fc::uint128_t diff_amount = pob_amount - pol_amount;
1356 if( diff_amount <= voting_stake[vid_worker] )
1358 auto diff_value = (
static_cast<fc::uint128_t
>( pol_amount ) * pob_value ) / pob_amount;
1359 base_value += ( pob_value - diff_value );
1360 voting_stake[vid_worker] +=
static_cast<uint64_t
>( base_value - diff_amount );
1364 base_value += (
static_cast<fc::uint128_t
>( voting_stake[vid_worker] ) * pob_value ) / pob_amount;
1365 voting_stake[vid_worker] =
static_cast<uint64_t
>( base_value );
1370 if( 0 == voting_stake[vid_worker] )
1373 const auto& opinion_account_stats = ( directly_voting ? stats : opinion_account.
statistics( d ) );
1376 if( !hf2103_passed )
1378 voting_stake[vid_committee] = voting_stake[vid_worker];
1379 voting_stake[vid_witness] = voting_stake[vid_worker];
1380 num_committee_voting_stake = voting_stake[vid_worker];
1381 vp_all = voting_stake[vid_worker];
1382 vp_active = voting_stake[vid_worker];
1383 vp_committee = voting_stake[vid_worker];
1384 vp_witness = voting_stake[vid_worker];
1385 vp_worker = voting_stake[vid_worker];
1389 vp_all = voting_stake[vid_worker];
1390 vp_active = voting_stake[vid_worker];
1391 if( !directly_voting )
1394 voting_stake[vid_worker], stats.
last_vote_time, *delegator_recalc_times );
1395 vp_active = voting_stake[vid_worker];
1398 voting_stake[vid_worker], opinion_account_stats.last_vote_time, *witness_recalc_times );
1399 vp_witness = voting_stake[vid_witness];
1401 voting_stake[vid_worker], opinion_account_stats.last_vote_time, *committee_recalc_times );
1402 vp_committee = voting_stake[vid_committee];
1403 num_committee_voting_stake = voting_stake[vid_committee];
1407 voting_stake[vid_worker], opinion_account_stats.last_vote_time, *worker_recalc_times );
1408 vp_worker = voting_stake[vid_worker];
1412 d.
modify( opinion_account_stats, [vp_all,vp_active,vp_committee,vp_witness,vp_worker,
this]
1416 update_stats.vp_all = vp_all;
1417 update_stats.vp_active = vp_active;
1418 update_stats.vp_committee = vp_committee;
1419 update_stats.vp_witness = vp_witness;
1420 update_stats.vp_worker = vp_worker;
1421 update_stats.vote_tally_time = now;
1425 update_stats.vp_all += vp_all;
1426 update_stats.vp_active += vp_active;
1427 update_stats.vp_committee += vp_committee;
1428 update_stats.vp_witness += vp_witness;
1429 update_stats.vp_worker += vp_worker;
1435 uint32_t offset =
id.instance();
1436 uint32_t type = std::min(
id.type(), vote_id_type::vote_type::worker );
1438 if( offset < d._vote_tally_buffer.size() )
1439 d._vote_tally_buffer[offset] += voting_stake[type];
1443 if( voting_stake[vid_witness] > 0
1447 d._witness_count_histogram_buffer[offset] += voting_stake[vid_witness];
1450 if( num_committee_voting_stake > 0
1454 d._committee_count_histogram_buffer[offset] += num_committee_voting_stake;
1457 d._total_voting_stake[vid_committee] += num_committee_voting_stake;
1458 d._total_voting_stake[vid_witness] += voting_stake[vid_witness];
1463 vote_tally_helper tally_helper(*
this);
1465 perform_account_maintenance( tally_helper );
1467 struct clear_canary {
1468 explicit clear_canary(vector<uint64_t>& target): target(target){}
1469 clear_canary(
const clear_canary& ) =
delete;
1470 ~clear_canary() { target.clear(); }
1472 vector<uint64_t>& target;
1474 clear_canary a(_witness_count_histogram_buffer);
1475 clear_canary b(_committee_count_histogram_buffer);
1476 clear_canary c(_vote_tally_buffer);
1479 update_active_witnesses();
1480 update_active_committee_members();
1481 update_worker_votes();
1496 auto next_maintenance_time = dgpo.next_maintenance_time;
1497 auto maintenance_interval = gpo.parameters.maintenance_interval;
1499 if( next_maintenance_time <= next_block.
timestamp )
1521 auto y = (
head_block_time() - next_maintenance_time).to_seconds() / maintenance_interval;
1522 next_maintenance_time += (uint32_t)( (y+1) * maintenance_interval );
1526 if( (dgpo.next_maintenance_time < HARDFORK_613_TIME) && (next_maintenance_time >= HARDFORK_613_TIME) )
1530 bool to_process_hf_343 =
false;
1531 if( (dgpo.next_maintenance_time <= HARDFORK_CORE_343_TIME) && (next_maintenance_time > HARDFORK_CORE_343_TIME) )
1532 to_process_hf_343 =
true;
1535 if( (dgpo.next_maintenance_time <= HARDFORK_CORE_868_890_TIME)
1536 && (next_maintenance_time > HARDFORK_CORE_868_890_TIME) )
1540 bool to_process_hf_1270 =
false;
1541 if( (dgpo.next_maintenance_time <= HARDFORK_CORE_1270_TIME) && (next_maintenance_time > HARDFORK_CORE_1270_TIME) )
1542 to_process_hf_1270 =
true;
1545 if ( dgpo.next_maintenance_time <= HARDFORK_CORE_1465_TIME && next_maintenance_time > HARDFORK_CORE_1465_TIME )
1549 if ( dgpo.next_maintenance_time <= HARDFORK_CORE_2103_TIME && next_maintenance_time > HARDFORK_CORE_2103_TIME )
1553 if ( dgpo.next_maintenance_time <= HARDFORK_CORE_2262_TIME && next_maintenance_time > HARDFORK_CORE_2262_TIME )
1557 if ( dgpo.next_maintenance_time <= HARDFORK_CORE_2281_TIME && next_maintenance_time > HARDFORK_CORE_2281_TIME )
1561 bool match_call_orders_for_hf_2481 =
false;
1562 if( (dgpo.next_maintenance_time <= HARDFORK_CORE_2481_TIME) && (next_maintenance_time > HARDFORK_CORE_2481_TIME) )
1563 match_call_orders_for_hf_2481 =
true;
1572 if( to_process_hf_343 )
1579 if( to_process_hf_1270 )
1582 update_bitasset_current_feeds(*
this);
1587 if( match_call_orders_for_hf_2481 )
1592 process_bitassets();
share_type from_unused_witness_budget
share_type total_core_pol
Total amount of core token in other tickets.
time_point_sec full_power_time
share_type core_in_balance
uint32_t next_available_vote_id
asset_id_type asset_id
The asset this object belong to.
time_point_sec last_budget_time
static const vote_recalc_options & witness()
void modify(const T &obj, const Lambda &m)
void update_call_orders_hf_343(database &db)
chain_parameters parameters
void delete_expired_custom_auths(database &db)
Remove any custom active authorities whose expiration dates are in the past.
Wraps a derived index to intercept calls to create, modify, and remove so that callbacks may be fired...
bool upgrade_to_lifetime_member
If true, the account will be upgraded to a lifetime member; otherwise, it will add a year to the subs...
share_type leftover_worker_funds
Unused budget.
void adjust_balance(account_id_type account, asset delta)
Adjust a particular account's balance in a given asset by a delta.
vote_recalc_times get_vote_recalc_times(const time_point_sec now) const
share_type reserved(const DB &db) const
Manage an account's membership statusThis operation is used to upgrade an account to a member...
bool fill_or_kill
If this flag is set the entire order must be filled or the operation is rejected. ...
void finish(authority &out_auth)
contains properties that only apply to bitassets (market issued assets)
uint64_t time_since_last_budget
const index_type & indices() const
time_point_sec zero_power_time
special_authority active_special_authority
uint16_t accounts_per_fee_scale
number of accounts between fee scalings
share_type requested_witness_budget
Witness budget requested by the committee.
time_point_sec head_block_time() const
This class represents an account on the object graphAccounts are the primary unit of authority on the...
Maintains global state information (committee_member list, current fees)This is an implementation det...
tracks the blockchain state in an extensible manner
share_type witness_budget
const IndexType & get_index_type() const
share_type max_supply
Maximum supply.
void process_hf_1465(database &db)
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT
Represents the canonical account for specifying you will vote directly (as opposed to a proxy) ...
tracks debt and call price information
vector< uint16_t > power_percents_to_subtract
Used to generate a useful error report when an exception is thrown.At each level in the stack where t...
uint32_t total_recalc_seconds
void add(Component who, uint64_t votes)
const asset_object & get_core_asset() const
const asset_dynamic_data_object & dynamic_data(const DB &db) const
static const vote_recalc_options & worker()
optional< account_id_type > buyback_account
time_point_sec vote_tally_time
#define GRAPHENE_CORE_ASSET_CYCLE_RATE
void operator()(W &worker) const
immutable_chain_parameters immutable_parameters
share_type total_pol_value
Total value of tickets whose current type is not lock_forever.
uint8_t account_fee_scale_bitshifts
number of times to left bitshift account registration fee at each scaling
price call_price
Collateral / Debt.
share_type current_supply
Current supply.
uint16_t min_committee_member_count
visitor::result_type visit(visitor &v)
account_id_type issuer
ID of the account which issued this asset.
account_id_type voting_account
account_id_type account_id
vote_recalc_options(uint32_t f, uint32_t d, uint32_t s)
share_type from_accumulated_fees
bool is_configured(const database &db) const
void update_call_orders_hf_1270(database &db)
void create_buyback_orders(database &db)
provides stack-based nullable value similar to boost::optional
void execute_bid(const collateral_bid_object &bid, share_type debt_covered, share_type collateral_from_fund, const price_feed ¤t_feed)
void distribute_fba_balances(database &db)
flat_set< witness_id_type > active_witnesses
worker_pay_visitor(share_type pay, database &db)
bool check_call_orders(const asset_object &mia, bool enable_black_swan=true, bool for_new_limit_order=false, const asset_bitasset_data_object *bitasset_ptr=nullptr, bool mute_exceptions=false, bool skip_matching_settle_orders=false)
bool is_prediction_market
True if this asset implements a Prediction Market.
asset get_collateral() const
void cancel_bid(const collateral_bid_object &bid, bool create_virtual_op=true)
microseconds days(int64_t d)
void process_hf_868_890(database &db)
share_type supply_delta
Change in supply due to budget operations.
void process_hf_2262(database &db)
A one-time data process to set values of existing liquid tickets to zero.
uint32_t push_applied_operation(const operation &op, bool is_virtual=true)
static time_point_sec maximum()
object_id< SpaceID, TypeID > get_id() const
share_type witness_budget
static const vote_recalc_options & committee()
const T & get(const object_id_type &id) const
uint16_t maintenance_collateral_ratio
const T * find(const object_id_type &id) const
share_type total_pob_value
Total value of tickets whose current type is lock_forever.
flat_set< vote_id_type > votes
The price struct stores asset prices in the BitShares system.
uint16_t maximum_witness_count
maximum number of active witnesses
#define GRAPHENE_100_PERCENT
optional< vesting_balance_id_type > cashback_vb
const object & get(object_id_type id) const
flat_map< account_id_type, weight_type > account_auths
#define GRAPHENE_COMMITTEE_ACCOUNT
uint64_t get_recalced_voting_stake(const uint64_t stake, const time_point_sec last_vote_time, const vote_recalc_times &recalc_times) const
share_type total_core_inactive
Total amount of core token in inactive lock_forever tickets.
worker_type worker
ID of this worker's pay balance.
const chain_property_object & get_chain_properties() const
share_type accumulated_fba_fees
time_point_sec expiration
#define FC_CAPTURE_AND_RETHROW(...)
instructs the blockchain to attempt to sell one asset for anotherThe blockchain will atempt to sell a...
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
price_feed_with_icr current_feed
This is the currently active price feed, calculated from median_feed and other parameters.
tracks the asset information that changes frequentlyBecause the asset_object is very large it doesn't...
uint16_t min_witness_count
bool is_active(fc::time_point_sec now) const
void update_bitasset_current_feed(const asset_bitasset_data_object &bitasset, bool skip_median_update=false)
share_type total_inactive
const asset_dynamic_data_object & get_core_dynamic_data() const
time_point_sec last_vote_time
last time voted
bids of collateral for debt after a black swan
uint32_t accounts_registered_this_interval
optional< asset_id_type > designated_asset
An ID for some votable object.
time_point_sec next_maintenance_time
void match_call_orders(database &db)
Match call orders for all bitAssets, including PMs.
#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT
Represents the current committee members.
std::string to_detail_string(log_level ll=log_level::all) const
uint16_t maximum_committee_count
maximum number of active committee_members
share_type accumulated_fees
fees accumulate to be paid out over time
uint16_t initial_collateral_ratio
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
void deprecate_annual_members(database &db)
typename impl::transform< List, Transformer >::type transform
Transform elements of a typelist.
uint64_t total_votes_against
share_type daily_pay
Amount in CORE this worker will be paid each day.
void process_hf_2281(database &db)
A one-time data process to cancel all collateral bids for assets that disabled collateral bidding alr...
bool skip_fee_schedule_check
safe< int64_t > share_type
bool is_member(time_point_sec now) const
vector< committee_member_id_type > active_committee_members
share_type total_budget
Funds that can be released from reserve at maximum rate.
share_type witness_pay_per_block
CORE to be allocated to witnesses (per block)
the bitasset is to be fed by witnesses
const account_statistics_object & get_account_stats_by_owner(account_id_type owner) const
share_type from_initial_reserve
vote_id_type vote_against
Voting ID which represents disapproval of this worker.
uint32_t head_block_num() const
uint32_t weight_threshold
bitasset_options options
The tunable options for BitAssets are stored in this field.
Worker object contains the details of a blockchain worker. See The Blockchain Worker System for detai...
vote_id_type vote_for
Voting ID which represents approval of this worker.
limit_order_id_type order
A visitor for worker_type which calls pay_worker on the worker within.
account_statistics_id_type statistics
void update_top_n_authorities(database &db)
abstract base class for accessing objects indexed in various ways.
void remove(const object &obj)
constexpr int64_t GRAPHENE_MAX_SHARE_SUPPLY(1000000000000000LL)
Maintains global state information (committee_member list, current fees)This is an implementation det...
uint32_t sec_since_epoch() const
bool count_non_member_votes
set to false to restrict voting privlegages to member accounts
#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS
const dynamic_global_property_object & get_dynamic_global_properties() const
operation_result apply_operation(transaction_evaluation_state &eval_state, const operation &op, bool is_virtual=true)
the bitasset is to be fed by the committee
uint32_t seconds_per_step
share_type worker_budget_per_day
CORE to be allocated to workers (per day)
share_type current_supply
The number of shares currently in existence.
share_type approving_stake() const
time_point_sec last_vote_tally_time
flat_map< account_id_type, pair< time_point_sec, price_feed_with_icr > > feeds
void visit_special_authorities(const database &db, Visitor visit)
tracks information about a committee_member account.A committee_member is responsible for setting blo...
a ticket for governance voting
#define GRAPHENE_1_PERCENT
fee_schedule & get_mutable_fees()
account_id_type fee_paying_account
static price call_price(const asset &debt, const asset &collateral, uint16_t collateral_ratio)
share_type value
The current value of the ticket.
uint16_t num_committee_voted
Pre-calculated for better performance on chain maintenance.
static const vote_recalc_options & delegator()
uint32_t full_power_seconds
asset_id_type short_backing_asset
share_type total_core_pob
Total amount of core token in active lock_forever tickets.
share_type settlement_fund
Amount of collateral which is available for force settlement due to global settlement.
uint8_t block_interval
interval in seconds between blocks
share_type total_core_in_orders
const Operation::fee_parameters_type & get() const
special_authority owner_special_authority
optional< chain_parameters > pending_parameters
void process_hf_2103(database &db)
void split_fba_balance(database &db, uint64_t fba_id, uint16_t network_pct, uint16_t designated_asset_buyback_pct, uint16_t designated_asset_issuer_pct)
#define GRAPHENE_WITNESS_ACCOUNT
Represents the current witnesses.
const global_property_object & get_global_properties() const