move sizePush.

This commit is contained in:
Christopher Jeffrey 2016-05-16 15:58:07 -07:00
parent aa24f6facf
commit 3bb03c63fa
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 21 additions and 21 deletions

View File

@ -936,7 +936,7 @@ MTX.prototype.maxSize = function maxSize(options, force) {
if (redeem) {
prev = redeem;
sz = prev.getSize();
size += utils.sizePush(sz);
size += bcoin.script.sizePush(sz);
size += sz;
}
}

View File

@ -4296,6 +4296,26 @@ Script.isBadPush = function isBadPush(op) {
return false;
};
/**
* Calculate the size (including
* the opcode) of a pushdata.
* @param {Number} num - Pushdata data length.
* @returns {Number} size
*/
Script.sizePush = function sizePush(num) {
if (num <= 0x4b)
return 1;
if (num <= 0xff)
return 2;
if (num <= 0xffff)
return 3;
return 5;
};
/**
* Test an object to see if it is a Script.
* @param {Object} obj

View File

@ -2126,26 +2126,6 @@ utils.sizeVarint = function sizeVarint(num) {
return 9;
};
/**
* Calculate the size (including
* the opcode) of a pushdata.
* @param {Number} num - Pushdata data length.
* @returns {Number} size
*/
utils.sizePush = function sizePush(num) {
if (num <= 0x4b)
return 1;
if (num <= 0xff)
return 2;
if (num <= 0xffff)
return 3;
return 5;
};
/**
* Buffer comparator (memcmp + length comparison).
* @param {Buffer} a