]> Git Repo - VerusCoin.git/commitdiff
Rename method and use int64_t
authorEirik Ogilvie-Wigley <[email protected]>
Wed, 7 Aug 2019 16:05:01 +0000 (10:05 -0600)
committerEirik Ogilvie-Wigley <[email protected]>
Wed, 7 Aug 2019 16:05:01 +0000 (10:05 -0600)
src/consensus/params.cpp
src/consensus/params.h
src/gtest/test_foundersreward.cpp
src/main.cpp

index b0f2079e730ff4b1137f24a6ea9c06c96bb93cf2..1062df349c71e209e02b0c7ca827e315edd78add 100644 (file)
@@ -11,22 +11,22 @@ namespace Consensus {
         return NetworkUpgradeState(nHeight, *this, idx) == UPGRADE_ACTIVE;
     }
 
-    int Params::Halvings(int nHeight) const {
+    int Params::Halving(int nHeight) const {
         // zip208
         // Halving(height) :=
         // floor((height - SlowStartShift) / PreBlossomHalvingInterval), if not IsBlossomActivated(height)
         // floor((BlossomActivationHeight - SlowStartShift) / PreBlossomHalvingInterval + (height - BlossomActivationHeight) / PostBlossomHalvingInterval), otherwise
         if (NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM)) {
-            int blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight;
+            int64_t blossomActivationHeight = vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight;
             // Ideally we would say:
             // halvings = (blossomActivationHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nPreBlossomSubsidyHalvingInterval 
             //     + (nHeight - blossomActivationHeight) / consensusParams.nPostBlossomSubsidyHalvingInterval;
             // But, (blossomActivationHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nPreBlossomSubsidyHalvingInterval
             // would need to be treated as a rational number in order for this to work.
             // Define scaledHalvings := halvings * consensusParams.nPostBlossomSubsidyHalvingInterval;
-            int scaledHalvings = ((blossomActivationHeight - SubsidySlowStartShift()) * Consensus::BLOSSOM_POW_TARGET_SPACING_RATIO)
+            int64_t scaledHalvings = ((blossomActivationHeight - SubsidySlowStartShift()) * Consensus::BLOSSOM_POW_TARGET_SPACING_RATIO)
                 + (nHeight - blossomActivationHeight);
-            return scaledHalvings / nPostBlossomSubsidyHalvingInterval;
+            return (int) (scaledHalvings / nPostBlossomSubsidyHalvingInterval);
         } else {
             return (nHeight - SubsidySlowStartShift()) / nPreBlossomSubsidyHalvingInterval;
         }
index 84fff232a42ee65d9343d4a59afa99e93ba2f02e..a3bbbd3134c667d18affbcd96b8f06b4cb4616b3 100644 (file)
@@ -104,7 +104,7 @@ struct Params {
     int nPreBlossomSubsidyHalvingInterval;
     int nPostBlossomSubsidyHalvingInterval;
 
-    int Halvings(int nHeight) const;
+    int Halving(int nHeight) const;
 
     int GetLastFoundersRewardBlockHeight(int nHeight) const;
 
index 7eeb7fa0df454744e1fa59011a70553e355bd132..70826ae2a76a98d3322a072a3b1ac3c222df4871 100644 (file)
@@ -129,8 +129,8 @@ TEST(founders_reward_test, regtest_get_last_block_blossom) {
     int blossomActivationHeight = Consensus::PRE_BLOSSOM_REGTEST_HALVING_INTERVAL / 2; // = 75
     auto params = RegtestActivateBlossom(false, blossomActivationHeight);
     int lastFRHeight = params.GetLastFoundersRewardBlockHeight(blossomActivationHeight);
-    EXPECT_EQ(0, params.Halvings(lastFRHeight));
-    EXPECT_EQ(1, params.Halvings(lastFRHeight + 1));
+    EXPECT_EQ(0, params.Halving(lastFRHeight));
+    EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
     RegtestDeactivateBlossom();
 }
 
@@ -138,8 +138,8 @@ TEST(founders_reward_test, mainnet_get_last_block) {
     SelectParams(CBaseChainParams::MAIN);
     auto params = Params().GetConsensus();
     int lastFRHeight = GetLastFoundersRewardHeight(params);
-    EXPECT_EQ(0, params.Halvings(lastFRHeight));
-    EXPECT_EQ(1, params.Halvings(lastFRHeight + 1));
+    EXPECT_EQ(0, params.Halving(lastFRHeight));
+    EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
 }
 
 #define NUM_MAINNET_FOUNDER_ADDRESSES 48
index 3ebe6b3712f205b9cd73e97cdbc682a0a9beb57a..7447e2f32d527dbb7c3ce02f96aa4413926ec3d0 100644 (file)
@@ -1762,7 +1762,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
 
     assert(nHeight > consensusParams.SubsidySlowStartShift());
 
-    int halvings = consensusParams.Halvings(nHeight);
+    int halvings = consensusParams.Halving(nHeight);
 
     // Force block reward to zero when right shift is undefined.
     if (halvings >= 64)
This page took 0.030542 seconds and 4 git commands to generate.