Created
April 4, 2018 19:39
-
-
Save slaykovsky/c975b6db57bd2385ea6d48e8942e3e4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public double makeTxFees(Transaction tx) { | |
if (!this.isValidTx(tx)) { | |
return 0; | |
} | |
double inputValuesSum = tx.getInputs() | |
.parallelStream() | |
.map((x) -> new UTXO(x.prevTxHash, x.outputIndex)) | |
.filter((x) -> this.utxoPool.contains(x)) | |
.mapToDouble((x) -> this.utxoPool.getTxOutput(x).value) | |
.sum(); | |
double outputValuesSum = tx.getOutputs() | |
.parallelStream() | |
.mapToDouble((x) -> x.value) | |
.sum(); | |
return inputValuesSum - outputValuesSum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment