Skip to content

Commit

Permalink
enhance delegate stability
Browse files Browse the repository at this point in the history
  • Loading branch information
owenSai committed Mar 28, 2020
1 parent 11ff385 commit 0ccc6bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/Chain/libraries/blockchain/ChainInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,24 @@ namespace thinkyoung {
// just like in Bitcoin
ShareType ChainInterface::get_max_delegate_pay_issued_per_block()const
{
static const ShareType delegate_pay_inc[] = { 1500000, 1650000, 1815000, 1996000, 2196000,
2415000, 2657000, 2923000, 3215000, 3536000, 4000000};
static const uint32_t delegate_pay_inc_times = 11;

ShareType pay_per_block = ALP_MAX_DELEGATE_PAY_PER_BLOCK;
// static const time_point_sec start_timestamp = get_genesis_timestamp();
// static const uint32_t seconds_per_period = fc::days( 4 * 365 ).to_seconds(); // Ignore leap years, leap seconds, etc.
//
// const time_point_sec now = this->now();
// if( now >= start_timestamp )
// {
// const uint32_t elapsed_time = (now - start_timestamp).to_seconds();
// const uint32_t num_full_periods = elapsed_time / seconds_per_period;
// for( uint32_t i = 0; i < num_full_periods; ++i )
// pay_per_block /= 2;
// }
uint32_t head_block_num = get_head_block_num();
uint32_t inc_times = 0;

//if head_block_num is ALP_DELEGATE_PAY_BLOCK_NUM, switch to new pay
if (head_block_num >= ALP_DELEGATE_PAY_BLOCK_NUM)
{
inc_times = (head_block_num - ALP_DELEGATE_PAY_BLOCK_NUM) / ALP_DELEGATE_PAY_INC_NUM;
//get the pos of delegate_pay_inc
uint32_t pos = inc_times >= delegate_pay_inc_times ? (delegate_pay_inc_times - 1):inc_times;

//set the value
pay_per_block = delegate_pay_inc[pos];
}

return pay_per_block;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Chain/libraries/include/blockchain/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@
#define ALP_BLOCKCHAIN_EXTRA_SIGNATURE_FEE 1000
#define ALP_BLOCKCHAIN_TRANSACTION_MAX_DEPOSIT_NUM 100

//for delegate pay
#define ALP_DELEGATE_PAY_BLOCK_NUM 8524000
#define ALP_DELEGATE_PAY_INC_NUM 3150000

0 comments on commit 0ccc6bb

Please sign in to comment.