message: refactor rfc11 inflation adjustment calculations in consensus code
diff: @@ -944,14 +944,17 @@ int64_t GetProofOfStakeReward(int64_t nCoinAge, uint32_t nTime)
  int64_t nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear;
  if (IsProtocolV09(nTime)) {
  - int64_t nAnnualStake = GetAnnualStake(nTime) * 1000000;
  - int64_t nMoneySupply = chainActive.Tip()->nMoneySupply;
  - double nUnboundedInflationAdjustment = 365.0 * nMoneySupply / nAnnualStake;
  - double nInflationAdjustment = std::max(1.0, std::min(nUnboundedInflationAdjustment, 5.0));
  - int64_t nSubsidyNew = nSubsidy * nInflationAdjustment;
  + uint64_t nAnnualStake = GetAnnualStake(nTime);
  + uint64_t nMoneySupply = chainActive.Tip()->nMoneySupply;
  + CBigNum bnUnboundedInflationAdjustment = nMoneySupply;
  + bnUnboundedInflationAdjustment *= 365;
  + bnUnboundedInflationAdjustment /= nAnnualStake;
  + uint64_t nUnboundedInflationAdjustment = bnUnboundedInflationAdjustment.getuint64();
  + uint64_t nInflationAdjustment = std::max((uint64_t)1000000, std::min(nUnboundedInflationAdjustment, (uint64_t)5000000));
  + uint64_t nSubsidyNew = (nSubsidy * nInflationAdjustment) / 1000000;
  if (gArgs.GetBoolArg("-printcreation", false))
  - LogPrintf("%s: money supply %ld, annual stake %ld, unbound inflation %f, bound inflation %f, old subsidy %ld, new subsidy %ld\n", __func__, nMoneySupply, nAnnualStake, nUnboundedInflationAdjustment, nInflationAdjustment, nSubsidy, nSubsidyNew);
  + LogPrintf("%s: money supply %ld, annual stake %ld, unbound inflation %f, bound inflation %f, old subsidy %ld, new subsidy %ld\n", __func__, nMoneySupply, nAnnualStake, nUnboundedInflationAdjustment/1000000.0, nInflationAdjustment/1000000.0, nSubsidy, nSubsidyNew);
  nSubsidy = nSubsidyNew;
  }
  