提交 2d093424 编写于 作者: K Khaled Al-Hassanieh

Small fixes

上级 58b0d7f6
......@@ -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"},
......
......@@ -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 {
......
......@@ -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 ) {
......
......@@ -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 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册