From 2d093424c7f3ea4b0a1a7c223e7f505344258306 Mon Sep 17 00:00:00 2001 From: Khaled Al-Hassanieh Date: Mon, 7 May 2018 13:45:35 -0400 Subject: [PATCH] Small fixes --- contracts/eosio.system/eosio.system.abi | 13 +++++++++---- contracts/eosio.system/eosio.system.hpp | 4 ++-- contracts/eosio.system/producer_pay.cpp | 17 ++++++++++------- contracts/eosio.system/voting.cpp | 4 ++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/contracts/eosio.system/eosio.system.abi b/contracts/eosio.system/eosio.system.abi index ad5cee285..e4ac2ea10 100644 --- a/contracts/eosio.system/eosio.system.abi +++ b/contracts/eosio.system/eosio.system.abi @@ -123,9 +123,14 @@ "name": "eosio_global_state", "base": "eosio_parameters", "fields": [ - {"name":"total_ram_bytes_reserved", "type":"uint64"}, - {"name":"total_ram_stake", "type":"uint64"}, - {"name":"payment_per_block", "type":"uint64"} + {"name":"total_ram_bytes_reserved", "type":"uint64"}, + {"name":"total_ram_stake", "type":"asset"}, + {"name":"last_producer_schedule_update", "type":"time"}, + {"name":"last_pervote_bucket_fill", "type":"time"}, + {"name":"eos_bucket", "type":"asset"}, + {"name":"savings", "type":"asset"}, + {"name":"last_producer_schedule_id", "type":"checksum160"}, + {"name":"total_activatied_stake", "type":"int64"} ] },{ "name": "producer_info", @@ -182,7 +187,7 @@ {"name":"owner", "type":"account_name"}, {"name":"proxy", "type":"account_name"}, {"name":"producers", "type":"account_name[]"}, - {"name":"staked", "type":"uint64"}, + {"name":"staked", "type":"int64"}, {"name":"last_vote_weight", "type":"float64"}, {"name":"proxied_vote_weight", "type":"float64"}, {"name":"is_proxy", "type":"bool"}, diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index a3f1acdcc..82f38c254 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -37,13 +37,13 @@ namespace eosiosystem { eosio::asset savings; checksum160 last_producer_schedule_id; - int64_t total_activiated_stake = 0; + int64_t total_activated_stake = 0; // explicit serialization macro is not necessary, used here only to improve compilation time EOSLIB_SERIALIZE_DERIVED( eosio_global_state, eosio_parameters, (total_ram_bytes_reserved)(total_ram_stake) (last_producer_schedule_update) (last_pervote_bucket_fill) - (eos_bucket)(savings)(last_producer_schedule_id)(total_activiated_stake) ) + (eos_bucket)(savings)(last_producer_schedule_id)(total_activated_stake) ) }; struct producer_info { diff --git a/contracts/eosio.system/producer_pay.cpp b/contracts/eosio.system/producer_pay.cpp index 3f7e6aa2a..9173f82ac 100644 --- a/contracts/eosio.system/producer_pay.cpp +++ b/contracts/eosio.system/producer_pay.cpp @@ -26,18 +26,21 @@ namespace eosiosystem { void system_contract::onblock( block_timestamp timestamp, account_name producer ) { using namespace eosio; - + /** until activated stake crosses this threshold no new rewards are paid */ - if( _gstate.total_activiated_stake < 150'000'000'0000 ) + if( _gstate.total_activated_stake < 150'000'000'0000 ) return; if( _gstate.last_pervote_bucket_fill == 0 ) /// start the presses _gstate.last_pervote_bucket_fill = timestamp; - _producers.modify( _producers.get(producer), 0, [&](auto& p ) { - p.produced_blocks++; - p.last_produced_block_time = timestamp; - }); + auto prod = _producers.find(producer); + if ( prod != _producers.end() ) { + _producers.modify( prod, 0, [&](auto& p ) { + p.produced_blocks++; + p.last_produced_block_time = timestamp; + }); + } /// only update block producers once every minute, block_timestamp is in half seconds if( timestamp - _gstate.last_producer_schedule_update > 120 ) { @@ -91,7 +94,7 @@ namespace eosiosystem { using namespace eosio; require_auth(owner); - + auto prod = _producers.find( owner ); eosio_assert( prod != _producers.end(), "account name is not in producer list" ); if( prod->last_claim_time > 0 ) { diff --git a/contracts/eosio.system/voting.cpp b/contracts/eosio.system/voting.cpp index d5435fd0d..f95b7056a 100644 --- a/contracts/eosio.system/voting.cpp +++ b/contracts/eosio.system/voting.cpp @@ -137,11 +137,11 @@ namespace eosiosystem { /** * The first time someone votes we calculate and set last_vote_weight, since they cannot unstake until - * after total_activiated_stake hits threshold, we can use last_vote_weight to determine that this is + * after total_activated_stake hits threshold, we can use last_vote_weight to determine that this is * their first vote and should consider their stake activated. */ if( voter->last_vote_weight <= 0.0 ) { - _gstate.total_activiated_stake += voter->staked; + _gstate.total_activated_stake += voter->staked; } auto weight = int64_t(now() / (seconds_per_day * 7)) / double( 52 ); -- GitLab