From 21cae4224c329bec8a3e02cf1ae9dfcb6c968738 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 8 Apr 2016 15:26:41 -0700 Subject: [PATCH] block size. --- lib/bcoin/block.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index 7b612b12..05c50a29 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -71,24 +71,24 @@ Block.prototype.getRaw = function getRaw() { return raw; }; -Block.prototype.getVirtualSize = function getVirtualSize() { +Block.prototype.getVirtualSize = function getVirtualSize(force) { var size, witnessSize, base; - size = this.getSize(); - witnessSize = this.getWitnessSize(); + size = this.getSize(force); + witnessSize = this.getWitnessSize(force); base = size - witnessSize; return (base * 4 + witnessSize + 3) / 4 | 0; }; -Block.prototype.getSize = function getSize() { - if (this._size == null) +Block.prototype.getSize = function getSize(force) { + if (force || this._size === 0) this.getRaw(); return this._size; }; -Block.prototype.getWitnessSize = function getWitnessSize() { - if (this._witnessSize == null) +Block.prototype.getWitnessSize = function getWitnessSize(force) { + if (force || this._size === 0) this.getRaw(); return this._witnessSize; };