one day coinbase maturity (#1457)

* one day coinbase maturity

* make one day maturity a soft fork
This commit is contained in:
John Tromp
2018-09-04 11:59:55 +02:00
committed by Antioch Peverell
parent 63880f71c7
commit c359c8aaf2
7 changed files with 22 additions and 14 deletions
+4 -3
View File
@@ -41,15 +41,16 @@ pub fn reward(fee: u64) -> u64 {
REWARD + fee
}
/// Number of blocks before a coinbase matures and can be spent
pub const COINBASE_MATURITY: u64 = 1_000;
/// Block interval, in seconds, the network will tune its next_target for. Note
/// that we may reduce this value in the future as we get more data on mining
/// with Cuckoo Cycle, networks improve and block propagation is optimized
/// (adjusting the reward accordingly).
pub const BLOCK_TIME_SEC: u64 = 60;
/// Number of blocks before a coinbase matures and can be spent
/// set to nominal number of block in one day (1440 with 1-minute blocks)
pub const COINBASE_MATURITY: u64 = 24 * 60 * 60 / BLOCK_TIME_SEC;
/// Cuckoo-cycle proof size (cycle length)
pub const PROOFSIZE: usize = 42;
+10 -3
View File
@@ -50,6 +50,12 @@ pub const AUTOMATED_TESTING_COINBASE_MATURITY: u64 = 3;
/// User testing coinbase maturity
pub const USER_TESTING_COINBASE_MATURITY: u64 = 3;
/// Old coinbase maturity
/// TODO: obsolete for mainnet together with maturity code below
pub const OLD_COINBASE_MATURITY: u64 = 1_000;
/// soft-fork around Sep 17 2018 on testnet3
pub const COINBASE_MATURITY_FORK_HEIGHT: u64 = 100_000;
/// Testing cut through horizon in blocks
pub const TESTING_CUT_THROUGH_HORIZON: u32 = 20;
@@ -133,13 +139,14 @@ pub fn proofsize() -> usize {
}
}
/// Coinbase maturity
pub fn coinbase_maturity() -> u64 {
/// Coinbase maturity for coinbases to be spent at given height
pub fn coinbase_maturity(height: u64) -> u64 {
let param_ref = CHAIN_TYPE.read().unwrap();
match *param_ref {
ChainTypes::AutomatedTesting => AUTOMATED_TESTING_COINBASE_MATURITY,
ChainTypes::UserTesting => USER_TESTING_COINBASE_MATURITY,
_ => COINBASE_MATURITY,
_ => if height < COINBASE_MATURITY_FORK_HEIGHT { OLD_COINBASE_MATURITY }
else { COINBASE_MATURITY },
}
}