Skip to content

Instantly share code, notes, and snippets.

@kristjank
Last active August 16, 2019 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristjank/dac8707d0ead35407e8f43ec942c78a8 to your computer and use it in GitHub Desktop.
Save kristjank/dac8707d0ead35407e8f43ec942c78a8 to your computer and use it in GitHub Desktop.
Dynamic Fee calculation
/** 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