Skip to content

Commit

Permalink
For LIB, only count witnesses who didn't miss their last two blocks #…
Browse files Browse the repository at this point in the history
  • Loading branch information
theoreticalbts committed May 21, 2018
1 parent de0e1c8 commit ff7b01f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3405,6 +3405,7 @@ void database::update_global_dynamic_data( const signed_block& b )

modify( witness_missed, [&]( witness_object& w )
{
w.current_run = 0;
if( witness_missed.owner != b.witness )
{
//
Expand Down Expand Up @@ -3490,6 +3491,9 @@ void database::update_signing_witness(const witness_object& signing_witness, con
{
_wit.last_aslot = new_block_aslot;
_wit.last_confirmed_block_num = new_block.block_num();
if( _wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN )
_wit.last_supported_block_num = _wit.last_confirmed_block_num;
_wit.current_run++;
} );
} FC_CAPTURE_AND_RETHROW() }

Expand Down Expand Up @@ -3532,10 +3536,10 @@ void database::update_last_irreversible_block()
std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(),
[]( const witness_object* a, const witness_object* b )
{
return a->last_confirmed_block_num < b->last_confirmed_block_num;
return a->last_supported_block_num < b->last_supported_block_num;
} );

uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num;
uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_supported_block_num;

if( new_last_irreversible_block_num > dpo.last_irreversible_block_num )
{
Expand Down
7 changes: 6 additions & 1 deletion libraries/chain/include/steem/chain/witness_objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ namespace steem { namespace chain {
uint32_t total_missed = 0;
uint64_t last_aslot = 0;
uint64_t last_confirmed_block_num = 0;
/** Number of blocks produced since beginning of time or last missed block */
uint64_t current_run = 0;
/** Last block produced when current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */
uint64_t last_supported_block_num = 0;

/**
* Some witnesses have the job because they did a proof of work,
Expand Down Expand Up @@ -272,7 +276,8 @@ FC_REFLECT( steem::chain::witness_object,
(owner)
(created)
(url)(votes)(schedule)(virtual_last_update)(virtual_position)(virtual_scheduled_time)(total_missed)
(last_aslot)(last_confirmed_block_num)(pow_worker)(signing_key)
(last_aslot)(last_confirmed_block_num)(current_run)(last_supported_block_num)
(pow_worker)(signing_key)
(props)
(sbd_exchange_rate)(last_sbd_exchange_update)
(last_work)
Expand Down
1 change: 1 addition & 0 deletions libraries/protocol/get_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fc::variant_object get_config()
#endif
result["STEEM_INIT_SUPPLY"] = STEEM_INIT_SUPPLY;
result["STEEM_INIT_TIME"] = STEEM_INIT_TIME;
result["STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN"] = STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN;
result["STEEM_IRREVERSIBLE_THRESHOLD"] = STEEM_IRREVERSIBLE_THRESHOLD;
result["STEEM_LIQUIDITY_APR_PERCENT"] = STEEM_LIQUIDITY_APR_PERCENT;
result["STEEM_LIQUIDITY_REWARD_BLOCKS"] = STEEM_LIQUIDITY_REWARD_BLOCKS;
Expand Down
2 changes: 2 additions & 0 deletions libraries/protocol/include/steem/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@
#define STEEM_MAX_URL_LENGTH 127

#define STEEM_IRREVERSIBLE_THRESHOLD (75 * STEEM_1_PERCENT)
/** Irreversibility only counts blocks produced if wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */
#define STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN 2

#define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH ( fc::uint128(uint64_t(-1)) )
#define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH2 ( fc::uint128::max_value() )
Expand Down

0 comments on commit ff7b01f

Please sign in to comment.