Skip to content

Commit 0ccc6bb

Browse files
committed
enhance delegate stability
1 parent 11ff385 commit 0ccc6bb

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/Chain/libraries/blockchain/ChainInterface.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,24 @@ namespace thinkyoung {
8585
// just like in Bitcoin
8686
ShareType ChainInterface::get_max_delegate_pay_issued_per_block()const
8787
{
88+
static const ShareType delegate_pay_inc[] = { 1500000, 1650000, 1815000, 1996000, 2196000,
89+
2415000, 2657000, 2923000, 3215000, 3536000, 4000000};
90+
static const uint32_t delegate_pay_inc_times = 11;
91+
8892
ShareType pay_per_block = ALP_MAX_DELEGATE_PAY_PER_BLOCK;
89-
// static const time_point_sec start_timestamp = get_genesis_timestamp();
90-
// static const uint32_t seconds_per_period = fc::days( 4 * 365 ).to_seconds(); // Ignore leap years, leap seconds, etc.
91-
//
92-
// const time_point_sec now = this->now();
93-
// if( now >= start_timestamp )
94-
// {
95-
// const uint32_t elapsed_time = (now - start_timestamp).to_seconds();
96-
// const uint32_t num_full_periods = elapsed_time / seconds_per_period;
97-
// for( uint32_t i = 0; i < num_full_periods; ++i )
98-
// pay_per_block /= 2;
99-
// }
93+
uint32_t head_block_num = get_head_block_num();
94+
uint32_t inc_times = 0;
95+
96+
//if head_block_num is ALP_DELEGATE_PAY_BLOCK_NUM, switch to new pay
97+
if (head_block_num >= ALP_DELEGATE_PAY_BLOCK_NUM)
98+
{
99+
inc_times = (head_block_num - ALP_DELEGATE_PAY_BLOCK_NUM) / ALP_DELEGATE_PAY_INC_NUM;
100+
//get the pos of delegate_pay_inc
101+
uint32_t pos = inc_times >= delegate_pay_inc_times ? (delegate_pay_inc_times - 1):inc_times;
102+
103+
//set the value
104+
pay_per_block = delegate_pay_inc[pos];
105+
}
100106

101107
return pay_per_block;
102108
}

src/Chain/libraries/include/blockchain/Config.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@
131131
#define ALP_BLOCKCHAIN_EXTRA_SIGNATURE_FEE 1000
132132
#define ALP_BLOCKCHAIN_TRANSACTION_MAX_DEPOSIT_NUM 100
133133

134+
//for delegate pay
135+
#define ALP_DELEGATE_PAY_BLOCK_NUM 8524000
136+
#define ALP_DELEGATE_PAY_INC_NUM 3150000

0 commit comments

Comments
 (0)