11 using namespace sysio;
13 require_auth(get_self());
19 checksum256 previous_block_id;
21 _ds >> timestamp >> producer >> confirmed >> previous_block_id;
25 add_to_blockinfo_table(previous_block_id, timestamp);
44 auto prod = _producers.find( producer.value );
45 if ( prod != _producers.end() ) {
47 _producers.modify( prod, same_payer, [&](
auto&
p ) {
54 update_elected_producers( timestamp );
58 auto idx = bids.get_index<
"highbid"_n>();
59 auto highest = idx.lower_bound( std::numeric_limits<uint64_t>::max()/2 );
60 if( highest != idx.end() &&
61 highest->high_bid > 0 &&
62 (current_time_point() - highest->last_bid_time) >
microseconds(useconds_per_day) &&
67 channel_namebid_to_rex( highest->high_bid );
68 idx.modify( highest, same_payer, [&](
auto& b ){
69 b.high_bid = -b.high_bid;
77 require_auth( owner );
79 const auto& prod = _producers.get( owner.value );
80 check( prod.active(),
"producer does not have an active key" );
83 "cannot claim rewards until the chain is activated (at least 15% of all tokens participate in voting)" );
85 const auto ct = current_time_point();
87 check( ct - prod.last_claim_time >
microseconds(useconds_per_day),
"already claimed rewards within past day" );
93 double additional_inflation = (_gstate4.
continuous_rate * double(token_supply.amount) * double(usecs_since_last_fill)) /
double(useconds_per_year);
94 check( additional_inflation <=
double(std::numeric_limits<int64_t>::max() - ((1ll << 10) - 1)),
95 "overflow in calculating new tokens to be issued; inflation rate is too high" );
96 int64_t new_tokens = (additional_inflation < 0.0) ? 0 :
static_cast<int64_t>(additional_inflation);
99 int64_t to_savings = new_tokens - to_producers;
101 int64_t to_per_vote_pay = to_producers - to_per_block_pay;
103 if( new_tokens > 0 ) {
106 issue_act.send( get_self(),
asset(new_tokens, core_symbol()),
"issue tokens for producer pay and savings" );
110 if( to_savings > 0 ) {
111 transfer_act.send( get_self(),
saving_account,
asset(to_savings, core_symbol()),
"unallocated inflation" );
113 if( to_per_block_pay > 0 ) {
114 transfer_act.send( get_self(),
bpay_account,
asset(to_per_block_pay, core_symbol()),
"fund per-block bucket" );
116 if( to_per_vote_pay > 0 ) {
117 transfer_act.send( get_self(),
vpay_account,
asset(to_per_vote_pay, core_symbol()),
"fund per-vote bucket" );
127 auto prod2 = _producers2.find( owner.value );
131 const auto last_claim_plus_3days = prod.last_claim_time +
microseconds(3 * useconds_per_day);
133 bool crossed_threshold = (last_claim_plus_3days <= ct);
134 bool updated_after_threshold =
true;
135 if ( prod2 != _producers2.end() ) {
136 updated_after_threshold = (last_claim_plus_3days <= prod2->last_votepay_share_update);
140 info.last_votepay_share_update = ct;
149 int64_t producer_per_block_pay = 0;
154 double new_votepay_share = update_producer_votepay_share( prod2,
156 updated_after_threshold ? 0.0 : prod.total_votes,
160 int64_t producer_per_vote_pay = 0;
162 double total_votepay_share = update_total_votepay_share( ct );
163 if( total_votepay_share > 0 && !crossed_threshold ) {
174 if( producer_per_vote_pay < min_pervote_daily_pay ) {
175 producer_per_vote_pay = 0;
182 update_total_votepay_share( ct, -new_votepay_share, (updated_after_threshold ? prod.total_votes : 0.0) );
184 _producers.modify( prod, same_payer, [&](
auto&
p) {
185 p.last_claim_time = ct;
189 if ( producer_per_block_pay > 0 ) {
191 transfer_act.send(
bpay_account, owner,
asset(producer_per_block_pay, core_symbol()),
"producer block pay" );
193 if ( producer_per_vote_pay > 0 ) {
195 transfer_act.send(
vpay_account, owner,
asset(producer_per_vote_pay, core_symbol()),
"producer vote pay" );