Last active
August 16, 2019 09:02
-
-
Save kristjank/dac8707d0ead35407e8f43ec942c78a8 to your computer and use it in GitHub Desktop.
Dynamic Fee calculation
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
/** Calculates delegate fee for processing and forging if transaction | |
* @param {Number} Fee price per byte in ARKTOSHI as set by forger/delegate in delegate.json setting feeMultiplier | |
* @param {Transaction} Transaction for which we calculate dynamic fee | |
* @returns {Number} Calculated dynamic fee in ARKTOSHI | |
*/ | |
calculateFee (feeMultiplier, transaction) { | |
if (feeMultiplier <= 0) { | |
feeMultiplier = 1 | |
} | |
// We get the transactions offset for a transaction type and | |
// Calculate the dynamic fee based on AIP Formula | |
return (this.get(transaction.type) + (transaction.serialized.length)) * feeMultiplier | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment