From 39b941516d56abe35583b0020b025d7efd6f0044 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 21 Jan 2017 14:40:51 -0800 Subject: [PATCH] chainentry: minor. --- lib/blockchain/chainentry.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/blockchain/chainentry.js b/lib/blockchain/chainentry.js index 84890f01..1041a03c 100644 --- a/lib/blockchain/chainentry.js +++ b/lib/blockchain/chainentry.js @@ -501,7 +501,7 @@ ChainEntry.prototype.toJSON = function toJSON() { bits: this.bits, nonce: this.nonce, height: this.height, - chainwork: this.chainwork.toString(10) + chainwork: this.chainwork.toString('hex', 64) }; }; @@ -514,12 +514,12 @@ ChainEntry.prototype.toJSON = function toJSON() { ChainEntry.prototype.fromJSON = function fromJSON(json) { assert(json, 'Block data is required.'); assert(typeof json.hash === 'string'); - assert(util.isNumber(json.version)); + assert(util.isUInt32(json.version)); assert(typeof json.prevBlock === 'string'); assert(typeof json.merkleRoot === 'string'); - assert(util.isNumber(json.ts)); - assert(util.isNumber(json.bits)); - assert(util.isNumber(json.nonce)); + assert(util.isUInt32(json.ts)); + assert(util.isUInt32(json.bits)); + assert(util.isUInt32(json.nonce)); assert(typeof json.chainwork === 'string'); this.hash = util.revHex(json.hash); @@ -530,7 +530,7 @@ ChainEntry.prototype.fromJSON = function fromJSON(json) { this.bits = json.bits; this.nonce = json.nonce; this.height = json.height; - this.chainwork = new BN(json.chainwork, 10); + this.chainwork = new BN(json.chainwork, 'hex'); return this; }; @@ -583,7 +583,7 @@ ChainEntry.prototype.inspect = function inspect() { ChainEntry.isChainEntry = function isChainEntry(obj) { return obj - && obj.chainwork !== undefined + && BN.isBN(obj.chainwork) && typeof obj.getMedianTime === 'function'; };