tx: add sigops vsize calculation.
This commit is contained in:
parent
72d5eec710
commit
808d8678a6
@ -324,6 +324,20 @@ TX.prototype.getVirtualSize = function getVirtualSize() {
|
||||
return (this.getWeight() + scale - 1) / scale | 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the virtual size of the transaction
|
||||
* (weighted against bytes per sigop cost).
|
||||
* @param {Number} sigops - Sigops cost.
|
||||
* @returns {Number} vsize
|
||||
*/
|
||||
|
||||
TX.prototype.getSigopsSize = function getSigopsSize(sigops) {
|
||||
var scale = constants.WITNESS_SCALE_FACTOR;
|
||||
var bytes = constants.tx.BYTES_PER_SIGOP;
|
||||
var weight = Math.max(this.getWeight(), sigops * bytes);
|
||||
return (weight + scale - 1) / scale | 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the weight of the transaction.
|
||||
* Note that this is cached.
|
||||
|
||||
@ -422,6 +422,7 @@ exports.tx = {
|
||||
FREE_THRESHOLD: exports.COIN * 144 / 250,
|
||||
MAX_SIGOPS: exports.block.MAX_SIGOPS / 5,
|
||||
MAX_SIGOPS_WEIGHT: exports.block.MAX_SIGOPS_WEIGHT / 5,
|
||||
BYTES_PER_SIGOP: 20,
|
||||
COINBASE_MATURITY: 100
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user