mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Minor boundary adjustments for 2nd PoW scaling
This commit is contained in:
parent
34646ddf51
commit
d0ed5cd4a3
1 changed files with 6 additions and 8 deletions
|
@ -72,10 +72,10 @@ pub const SECOND_POW_EDGE_BITS: u8 = 29;
|
||||||
/// Cuckoo graph sizes, changing this would hard fork
|
/// Cuckoo graph sizes, changing this would hard fork
|
||||||
pub const BASE_EDGE_BITS: u8 = 24;
|
pub const BASE_EDGE_BITS: u8 = 24;
|
||||||
|
|
||||||
/// maximum scaling factor for secondary pow, enforced in diff retargetting
|
/// Maximum scaling factor for secondary pow, enforced in diff retargetting
|
||||||
/// increasing scaling factor increases frequency of secondary blocks
|
/// increasing scaling factor increases frequency of secondary blocks
|
||||||
/// ONLY IN TESTNET4 LIMITED TO ABOUT 8 TIMES THE NATURAL SCALE
|
/// ONLY IN TESTNET4 LIMITED TO ABOUT 8 TIMES THE NATURAL SCALE
|
||||||
pub const MAX_SECOND_POW_SCALE: u64 = 8 << 11;
|
pub const MAX_SECONDARY_SCALING: u64 = 8 << 11;
|
||||||
|
|
||||||
/// Default number of blocks in the past when cross-block cut-through will start
|
/// Default number of blocks in the past when cross-block cut-through will start
|
||||||
/// happening. Needs to be long enough to not overlap with a long reorg.
|
/// happening. Needs to be long enough to not overlap with a long reorg.
|
||||||
|
@ -294,8 +294,6 @@ where
|
||||||
HeaderInfo::from_diff_scaling(Difficulty::from_num(difficulty), sec_pow_scaling)
|
HeaderInfo::from_diff_scaling(Difficulty::from_num(difficulty), sec_pow_scaling)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const MAX_SECONDARY_SCALING: u64 = (::std::u32::MAX / 70) as u64;
|
|
||||||
|
|
||||||
/// Factor by which the secondary proof of work difficulty will be adjusted
|
/// Factor by which the secondary proof of work difficulty will be adjusted
|
||||||
pub fn secondary_pow_scaling(height: u64, diff_data: &Vec<HeaderInfo>) -> u32 {
|
pub fn secondary_pow_scaling(height: u64, diff_data: &Vec<HeaderInfo>) -> u32 {
|
||||||
// median of past scaling factors, scaling is 1 if none found
|
// median of past scaling factors, scaling is 1 if none found
|
||||||
|
@ -317,10 +315,10 @@ pub fn secondary_pow_scaling(height: u64, diff_data: &Vec<HeaderInfo>) -> u32 {
|
||||||
let scaling = scaling_median * diff_data.len() as u64 * ratio / 100 / secondary_count as u64;
|
let scaling = scaling_median * diff_data.len() as u64 * ratio / 100 / secondary_count as u64;
|
||||||
|
|
||||||
// various bounds
|
// various bounds
|
||||||
let bounded_scaling = if scaling < scaling_median / 4 || scaling == 0 {
|
let bounded_scaling = if scaling < scaling_median / 2 || scaling == 0 {
|
||||||
max(scaling_median / 4, 1)
|
max(scaling_median / 2, 1)
|
||||||
} else if scaling > MAX_SECONDARY_SCALING || scaling > scaling_median * 4 {
|
} else if scaling > MAX_SECONDARY_SCALING || scaling > scaling_median * 2 {
|
||||||
min(MAX_SECONDARY_SCALING, scaling_median * 4)
|
min(MAX_SECONDARY_SCALING, scaling_median * 2)
|
||||||
} else {
|
} else {
|
||||||
scaling
|
scaling
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue