Handle new ANON v2 getblocktemplate with developement fee and superbl…#35
Handle new ANON v2 getblocktemplate with developement fee and superbl…#35egyptianbman merged 2 commits intos-nomp:masterfrom
Conversation
egyptianbman
left a comment
There was a problem hiding this comment.
Thank you for providing this PR! I just have a few minor requests.
lib/transactions.js
Outdated
| } | ||
| } else { | ||
|
|
||
| } else if(rpcData.coinbase_required_outputs && rpcData.coinbase_required_outputs.length){ |
There was a problem hiding this comment.
Can you fix the alignment in this block? (should be four spaces)
lib/transactions.js
Outdated
| // keep track of total the amount of all outputs (except superblock) in coinbase_required_outputs array | ||
| let required_outputs_total = 0; | ||
| // loop through coinbase_required_outputs and add them to our coinbase transaction | ||
| for(let i = 0; i < rpcData.coinbase_required_outputs.length; i++){ |
There was a problem hiding this comment.
This can be simplified with:
rpcData.coinbase_required_outputs.map(output => {
// do something with the output -- i.e. output.script or output.amount
})
lib/transactions.js
Outdated
| // let's find out if it's a superblock | ||
| // we ignore superblock's output value becuase it's not part of the block reward | ||
| // during superblocks the total output value of coinbase exceeds regular block reward | ||
| if(rpcData.coinbase_required_outputs[i].type !== "superblock") |
There was a problem hiding this comment.
if statements should have a space after the if as well as curly braces (even if only one-line).
lib/transactions.js
Outdated
| for(let i = 0; i < rpcData.coinbase_required_outputs.length; i++){ | ||
|
|
||
| let script = new Buffer(rpcData.coinbase_required_outputs[i].script, 'hex') | ||
| let amount = rpcData.coinbase_required_outputs[i].amount; |
There was a problem hiding this comment.
Since these are only used once, it's preferred to pass the value directly to txb.addOutput below to minimize memory consumption.
lib/transactions.js
Outdated
| ) | ||
| } | ||
| // we want to calculate pool fee using miner reward only | ||
| blockReward.total = blockReward.total - required_outputs_total; |
There was a problem hiding this comment.
This can be simplified to: blockReward.total -= required_outputs_total
lib/transactions.js
Outdated
|
|
||
| // masternode reward | ||
| // what if there is no masternode winner? | ||
| if(masternodeAddrHash) |
There was a problem hiding this comment.
Can you fix the alignment of this block and add curly braces?
Handle new ANON v2 getblocktemplate with developement fee and superblocks
This PR handles ANON development fee, and superblocks which will be activated by a Spork pretty soon.
amount,script(hex),type.