-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix block rewards calculations #1
base: master
Are you sure you want to change the base?
Conversation
benzcash
commented
Dec 12, 2019
- take into account testnet/mainnet
- handle blossom activation rewards changes https://github.com/zcash/zips/blob/master/zip-0208.rst
closes zcash/zcash#4117 |
There are a few simple On the other hand, it wouldn't be hard to update the tests. What do people think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
lib/blocks.js
Outdated
@@ -352,6 +352,12 @@ BlockController.prototype.getBlockReward = function(height) { | |||
return 0; | |||
} | |||
|
|||
// If we've actived blossom, cut the reward in half | |||
// https://github.com/zcash/zips/blob/master/zip-0208.rst | |||
if (height > 653600) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition should be greater-or-equal.
lib/blocks.js
Outdated
// If we've actived blossom, cut the reward in half | ||
// https://github.com/zcash/zips/blob/master/zip-0208.rst | ||
if (height > 653600) { | ||
subsidy /= 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this way of dividing by 2 would work as well as incrementing halvings
as I proposed. I guess it's a matter of taste; I'm fine either way. (Also, of course, this would have to be conditional on testnet versus mainnet.)
I applied these changes to the testnet explorer. Can anyone spot check the Block Rewards and let me know if it looks good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK modulo comment.
@@ -135,7 +135,7 @@ BlockController.prototype.transformBlock = function(block, info) { | |||
confirmations: info.confirmations, | |||
previousblockhash: this._normalizePrevHash(blockObj.header.prevHash), | |||
nextblockhash: info.nextHash, | |||
reward: this.getBlockReward(info.height) / 1e8, | |||
reward: this.getBlockReward(info.height, (info.confirmations !== -1)) / 1e8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no better way to get which network we're on than this?