Add comments and fix typos
This commit is contained in:
parent
f9d6b3e7ef
commit
2972521323
|
@ -29,9 +29,12 @@ namespace Consensus {
|
|||
}
|
||||
}
|
||||
|
||||
int Params::GetLastFoundersRewardBlockHeight(int nHeight) const {
|
||||
int Params::GetLastFoundersRewardBlockHeight(int nHeight) const {
|
||||
// zip208
|
||||
// FoundersRewardLastBlockHeight := max({ height ⦂ N | Halving(height) < 1 })
|
||||
// Halving(h) is defined as floor(f(h)) where f is a strictly increasing rational
|
||||
// function, so it's sufficient to solve for f(height) = 1 in the rationals and
|
||||
// then take ceiling(height - 1).
|
||||
// H := blossom activation height; SS := SubsidySlowStartShift(); R := BLOSSOM_POW_TARGET_SPACING_RATIO
|
||||
// preBlossom:
|
||||
// 1 = (height - SS) / preInterval
|
||||
|
@ -43,6 +46,7 @@ namespace Consensus {
|
|||
bool blossomActive = NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM);
|
||||
if (blossomActive) {
|
||||
int blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight;
|
||||
// The following calculation depends on BLOSSOM_POW_TARGET_SPACING_RATIO being an integer.
|
||||
return blossomActivationHeight + nPostBlossomSubsidyHalvingInterval
|
||||
+ (SubsidySlowStartShift() - blossomActivationHeight) * BLOSSOM_POW_TARGET_SPACING_RATIO - 1;
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "random.h"
|
||||
#include "utiltest.h"
|
||||
|
||||
void TestDifficultyAveragigingImpl(const Consensus::Params& params)
|
||||
void TestDifficultyAveragingImpl(const Consensus::Params& params)
|
||||
{
|
||||
size_t lastBlk = 2*params.nPowAveragingWindow;
|
||||
size_t firstBlk = lastBlk - params.nPowAveragingWindow;
|
||||
|
@ -75,11 +75,11 @@ void TestDifficultyAveragigingImpl(const Consensus::Params& params)
|
|||
|
||||
TEST(PoW, DifficultyAveraging) {
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
TestDifficultyAveragigingImpl(Params().GetConsensus());
|
||||
TestDifficultyAveragingImpl(Params().GetConsensus());
|
||||
}
|
||||
|
||||
TEST(PoW, DifficultyAveragingBlossom) {
|
||||
TestDifficultyAveragigingImpl(RegtestActivateBlossom(true));
|
||||
TestDifficultyAveragingImpl(RegtestActivateBlossom(true));
|
||||
RegtestDeactivateBlossom();
|
||||
}
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(PartitionAlertBlossomActivates)
|
|||
{
|
||||
// 48 pre blossom blocks, 96 blossom blocks will take 48 * 150s + 96 * 75s = 4hrs
|
||||
// in the slow case, all of the blocks will be blossom blocks
|
||||
// in the fast case, 96 blocks will be blossom => 96 * 75s * 2/5 = 2880s spent on on blossom
|
||||
// in the fast case, 96 blocks will be blossom => 96 * 75s * 2/5 = 2880s spent on blossom
|
||||
// => (14400 - 2880) / (150 * 2/5) = 11520 / 60 = 192 pre blossom blocks
|
||||
PartitionAlertTestImpl(RegtestActivateBlossom(false, 799 - 96), 2000000000, 144, 12 * 2, 192 + 96);
|
||||
RegtestDeactivateBlossom();
|
||||
|
|
Loading…
Reference in New Issue