improve block.getVirtualSize.
This commit is contained in:
parent
044d54e12e
commit
646b3c3028
@ -71,6 +71,12 @@ Block.prototype.getRaw = function getRaw() {
|
||||
return raw;
|
||||
};
|
||||
|
||||
Block.prototype._getSize = function _getSize() {
|
||||
var sizes = bcoin.protocol.framer.block._sizes(this);
|
||||
this._size = sizes.size;
|
||||
this._witnessSize = sizes.witnessSize;
|
||||
};
|
||||
|
||||
Block.prototype.getVirtualSize = function getVirtualSize(force) {
|
||||
var size, witnessSize, base;
|
||||
|
||||
@ -83,13 +89,13 @@ Block.prototype.getVirtualSize = function getVirtualSize(force) {
|
||||
|
||||
Block.prototype.getSize = function getSize(force) {
|
||||
if (force || this._size === 0)
|
||||
this.getRaw();
|
||||
this._getSize();
|
||||
return this._size;
|
||||
};
|
||||
|
||||
Block.prototype.getWitnessSize = function getWitnessSize(force) {
|
||||
if (force || this._size === 0)
|
||||
this.getRaw();
|
||||
this._getSize();
|
||||
return this._witnessSize;
|
||||
};
|
||||
|
||||
|
||||
@ -366,7 +366,7 @@ MinerBlock.prototype.updateMerkle = function updateMerkle() {
|
||||
};
|
||||
|
||||
MinerBlock.prototype.addTX = function addTX(tx) {
|
||||
var size = this.block.getVirtualSize() + tx.getVirtualSize();
|
||||
var size = this.block.getVirtualSize(true) + tx.getVirtualSize();
|
||||
|
||||
// Deliver me from the block size debate, please
|
||||
if (size > constants.blocks.maxSize)
|
||||
|
||||
@ -970,7 +970,7 @@ Script.prototype.interpret = function interpret(stack, flags, tx, index, version
|
||||
|
||||
n = Script.num(stack.pop(), flags).toNumber();
|
||||
|
||||
if (!(n >= 1 && n <= 15))
|
||||
if (!(n >= 1 && n <= constants.script.maxPubkeysPerMultisig))
|
||||
throw new ScriptError('`n` is out of bounds.', op, ip);
|
||||
|
||||
if (stack.length < n + 1)
|
||||
@ -1731,9 +1731,7 @@ Script.prototype.getInputType = function getInputType() {
|
||||
};
|
||||
|
||||
Script.getInputType = function getInputType(code, isWitness) {
|
||||
var type;
|
||||
|
||||
type = (Script.isPubkeyInput(code) && 'pubkey')
|
||||
var type = (Script.isPubkeyInput(code) && 'pubkey')
|
||||
|| (Script.isPubkeyhashInput(code) && 'pubkeyhash')
|
||||
|| (Script.isMultisigInput(code, isWitness) && 'multisig')
|
||||
|| (Script.isScripthashInput(code, isWitness) && 'scripthash')
|
||||
@ -1758,7 +1756,7 @@ Script.isUnknownInput = function isUnknownInput(code, isWitness) {
|
||||
return Script.getInputType(code, isWitness) === 'unknown';
|
||||
};
|
||||
|
||||
Script.createOutputScript = function(options) {
|
||||
Script.createOutputScript = function createOutputScript(options) {
|
||||
var script, m, n, hash, flags, address, redeem;
|
||||
|
||||
if (!options)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user