Skip to content

Commit

Permalink
Renamed produced_blocks to unpaid_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
zorba80 committed May 16, 2018
1 parent cdf5903 commit 366f234
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion contracts/eosio.system/eosio.system.abi
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{"name":"total_votes", "type":"float64"},
{"name":"producer_key", "type":"public_key"},
{"name":"url", "type":"string"},
{"name":"produced_blocks", "type":"uint32"},
{"name":"unpaid_blocks", "type":"uint32"},
{"name":"last_claim_time", "type":"uint64"},
{"name":"location", "type":"uint16"},
{"name":"time_became_active", "type":"uint32"},
Expand Down
6 changes: 3 additions & 3 deletions contracts/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace eosiosystem {
uint64_t free_ram()const { return max_ram_size - total_ram_bytes_reserved; }

uint64_t total_ram_bytes_reserved = 0;
int64_t total_ram_stake;
int64_t total_ram_stake = 0;

block_timestamp last_producer_schedule_update;
uint64_t last_pervote_bucket_fill = 0;
Expand All @@ -55,7 +55,7 @@ namespace eosiosystem {
double total_votes = 0;
eosio::public_key producer_key; /// a packed public key object
std::string url;
uint32_t produced_blocks;
uint32_t unpaid_blocks = 0;
uint64_t last_claim_time = 0;
uint16_t location = 0;
block_timestamp time_became_active;
Expand All @@ -67,7 +67,7 @@ namespace eosiosystem {

// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE( producer_info, (owner)(total_votes)(producer_key)(url)
(produced_blocks)(last_claim_time)(location)
(unpaid_blocks)(last_claim_time)(location)
(time_became_active)(last_produced_block_time) )
};

Expand Down
8 changes: 4 additions & 4 deletions contracts/eosio.system/producer_pay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eosiosystem {
if ( prod != _producers.end() ) {
_gstate.total_unpaid_blocks++;
_producers.modify( prod, 0, [&](auto& p ) {
p.produced_blocks++;
p.unpaid_blocks++;
p.last_produced_block_time = timestamp;
});
}
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace eosiosystem {
_gstate.last_pervote_bucket_fill = ct;
}

int64_t producer_per_block_pay = (_gstate.perblock_bucket * prod.produced_blocks) / _gstate.total_unpaid_blocks;
int64_t producer_per_block_pay = (_gstate.perblock_bucket * prod.unpaid_blocks) / _gstate.total_unpaid_blocks;
int64_t producer_per_vote_pay = int64_t((_gstate.pervote_bucket * prod.total_votes ) / _gstate.total_producer_vote_weight);
if( producer_per_vote_pay < 100'0000 ) {
producer_per_vote_pay = 0;
Expand All @@ -90,11 +90,11 @@ namespace eosiosystem {

_gstate.pervote_bucket -= producer_per_vote_pay;
_gstate.perblock_bucket -= producer_per_block_pay;
_gstate.total_unpaid_blocks -= prod.produced_blocks;
_gstate.total_unpaid_blocks -= prod.unpaid_blocks;

_producers.modify( prod, 0, [&](auto& p) {
p.last_claim_time = ct;
p.produced_blocks = 0;
p.unpaid_blocks = 0;
});

if( total_pay > 0 ) {
Expand Down
32 changes: 16 additions & 16 deletions unittests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const uint32_t initial_tot_unpaid_blocks = initial_global_state["total_unpaid_blocks"].as<uint32_t>();

prod = get_producer_info("defproducera");
const uint32_t unpaid_blocks = prod["produced_blocks"].as<uint32_t>();
const uint32_t unpaid_blocks = prod["unpaid_blocks"].as<uint32_t>();
BOOST_REQUIRE(1 < unpaid_blocks);
BOOST_REQUIRE_EQUAL(0, prod["last_claim_time"].as<uint64_t>());

Expand All @@ -1468,7 +1468,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t


prod = get_producer_info("defproducera");
BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as<uint32_t>());
BOOST_REQUIRE_EQUAL(1, prod["unpaid_blocks"].as<uint32_t>());
BOOST_REQUIRE_EQUAL(1, tot_unpaid_blocks);
const asset supply = get_token_supply();
const asset balance = get_balance(N(defproducera));
Expand Down Expand Up @@ -1527,7 +1527,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
const double initial_tot_vote_weight = initial_global_state["total_producer_vote_weight"].as<double>();

prod = get_producer_info("defproducera");
const uint32_t unpaid_blocks = prod["produced_blocks"].as<uint32_t>();
const uint32_t unpaid_blocks = prod["unpaid_blocks"].as<uint32_t>();
BOOST_REQUIRE(1 < unpaid_blocks);
BOOST_REQUIRE_EQUAL(initial_tot_unpaid_blocks, unpaid_blocks);
BOOST_REQUIRE(0 < prod["total_votes"].as<double>());
Expand All @@ -1551,7 +1551,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t


prod = get_producer_info("defproducera");
BOOST_REQUIRE_EQUAL(1, prod["produced_blocks"].as<uint32_t>());
BOOST_REQUIRE_EQUAL(1, prod["unpaid_blocks"].as<uint32_t>());
BOOST_REQUIRE_EQUAL(1, tot_unpaid_blocks);
const asset supply = get_token_supply();
const asset balance = get_balance(N(defproducera));
Expand Down Expand Up @@ -1662,7 +1662,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
auto prodv = get_producer_info( N(defproducerv) );
auto prodz = get_producer_info( N(defproducerz) );

BOOST_REQUIRE (0 == proda["produced_blocks"].as<uint32_t>() && 0 == prodz["produced_blocks"].as<uint32_t>());
BOOST_REQUIRE (0 == proda["unpaid_blocks"].as<uint32_t>() && 0 == prodz["unpaid_blocks"].as<uint32_t>());
BOOST_REQUIRE (0 == proda["last_claim_time"].as<uint64_t>() && 0 == prodz["last_claim_time"].as<uint64_t>());

// check vote ratios
Expand All @@ -1679,13 +1679,13 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
produce_blocks(23 * 12 + 20);
bool all_21_produced = true;
for (uint32_t i = 0; i < 21; ++i) {
if (0 == get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
all_21_produced = false;
}
}
bool rest_didnt_produce = true;
for (uint32_t i = 21; i < producer_names.size(); ++i) {
if (0 < get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
rest_didnt_produce = false;
}
}
Expand Down Expand Up @@ -1720,7 +1720,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);

const uint32_t initial_unpaid_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const uint32_t initial_unpaid_blocks = get_producer_info(prod_name)["unpaid_blocks"].as<uint32_t>();

BOOST_REQUIRE_EQUAL(success(), push_action(prod_name, N(claimrewards), mvo()("owner", prod_name)));

Expand All @@ -1733,7 +1733,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);

const uint32_t unpaid_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const uint32_t unpaid_blocks = get_producer_info(prod_name)["unpaid_blocks"].as<uint32_t>();



Expand Down Expand Up @@ -1795,7 +1795,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const asset initial_supply = get_token_supply();
const asset initial_balance = get_balance(prod_name);

const uint32_t initial_unpaid_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const uint32_t initial_unpaid_blocks = get_producer_info(prod_name)["unpaid_blocks"].as<uint32_t>();

BOOST_REQUIRE_EQUAL(success(), push_action(prod_name, N(claimrewards), mvo()("owner", prod_name)));

Expand All @@ -1808,7 +1808,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const asset supply = get_token_supply();
const asset balance = get_balance(prod_name);

const uint32_t unpaid_blocks = get_producer_info(prod_name)["produced_blocks"].as<uint32_t>();
const uint32_t unpaid_blocks = get_producer_info(prod_name)["unpaid_blocks"].as<uint32_t>();


const uint64_t usecs_between_fills = claim_time - initial_claim_time;
Expand Down Expand Up @@ -1857,7 +1857,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
{
bool all_newly_elected_produced = true;
for (uint32_t i = 21; i < producer_names.size(); ++i) {
if (0 == get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
all_newly_elected_produced = false;
}
}
Expand Down Expand Up @@ -1923,13 +1923,13 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try {
produce_blocks(21 * 12);
bool all_21_produced = true;
for (uint32_t i = 0; i < 21; ++i) {
if (0 == get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
all_21_produced= false;
}
}
bool rest_didnt_produce = true;
for (uint32_t i = 21; i < producer_names.size(); ++i) {
if (0 < get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
rest_didnt_produce = false;
}
}
Expand Down Expand Up @@ -1962,13 +1962,13 @@ BOOST_FIXTURE_TEST_CASE(producer_onblock_check, eosio_system_tester) try {
produce_blocks(21 * 12);
bool all_21_produced = true;
for (uint32_t i = 0; i < 21; ++i) {
if (0 == get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 == get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
all_21_produced= false;
}
}
bool rest_didnt_produce = true;
for (uint32_t i = 21; i < producer_names.size(); ++i) {
if (0 < get_producer_info(producer_names[i])["produced_blocks"].as<uint32_t>()) {
if (0 < get_producer_info(producer_names[i])["unpaid_blocks"].as<uint32_t>()) {
rest_didnt_produce = false;
}
}
Expand Down

0 comments on commit 366f234

Please sign in to comment.