That's not the issue. The value is to be returned in satoshis (multiplied by COIN). I thought I made that perfectly clear.
So, is nSubsidy1 and nSubsidy2 equal?
Can't tell if trolling or you can't figure it out =p
int64_t nRewardCoinYear;
nRewardCoinYear = MAX_MINT_PROOF_OF_STAKE; // 36.5 * COIN (main.h)
int64_t nCoinAge = 100 * COIN * 1;
int64_t nSubsidy = nCoinAge * nRewardCoinYear / 365 / COIN;
nSubsidy = 100 * COIN * 1 * 36.5 * COIN / 365 / COIN;
nSubsidy = 100 * COIN * 1 * 36.5 / 365;
Is it correct? Value is multiplied by COIN? nSubsidy in satoshi format?
ps
So, is nSubsidy1 and nSubsidy2 equal?
Sorry, thought you were totally trolling before. Yes, the bottom two nSubsidy are equal.
Thanks.
I wrote a little code to check it:
#include
#ifndef WIN32
#include
#endif
int main(void) {
int64_t COIN = 100000000;
int64_t MAX_MINT_PROOF_OF_STAKE = 36.5 * COIN;
int64_t nCoinAge = 100 * COIN * 1; // actually 100 coins one day aged
int64_t nRewardCoinYear = MAX_MINT_PROOF_OF_STAKE;
int64_t nSubsidy1 = nCoinAge * nRewardCoinYear / 365 / COIN;
int64_t nSubsidy2 = nCoinAge / COIN * nRewardCoinYear / 365;
printf("nSubsidy1= %ld\n", nSubsidy1);
printf("nSubsidy2= %ld\n", nSubsidy2);
}
And got results:
nSubsidy1 = -10780497
nSubsidy2 = 1000000000
So, results are equal for human, but computer thinks different )
In the first statement(one above the bottom) the earlier *COIN will be "reversed" by the later /COIN. But there's no reason to have that many operations. nSubsidy is the satoshi value of the block, so since age is the only real factor here. Usually (for neatness and speed) you want to convert to satoshis last and not keep switching between 1s(coin) and 10,000,000s(satoshi). You want something neat and readable like this:
const int64_t MAX_PROOF_OF_STAKE_DAILY_DIVISOR = 10; // 10% daily
nSubsidy = nCoinAge / MAX_PROOF_OF_STAKE_DAILY_DIVISOR * COIN;
Dividing by 10 is an easy way to multiply by 0.1 (daily age modifier towards reward) and to avoid using floating points. Then you multiply by COIN to calculate the satoshi value. This is actually exactly the same math as the existing algorithmn, but simplified, and another *COIN added. Here is the original logic and why we are dividing by 10:
nRewardCoinYear / 365 / COIN == 36.5 * COIN / 365 / COIN == 0.1There is NO need to do all of those operations other than if you're reading the code and have no idea what the 0.1 value means, or if you are trying to do math in years instead of days, like above. Now it looks pretty retarded, doesn't it?
Keep in mind that's untested so definitely don't use that until you test it, and it might be missing something(I'm sure it is)
Hope that makes a bit more sense.
Sure.