From 819795b1ae3dc20371fbd2a7e93927f963a86e4b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 2 Jun 2016 18:52:23 -0700 Subject: [PATCH] chainentry json. --- lib/bcoin/chainentry.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/bcoin/chainentry.js b/lib/bcoin/chainentry.js index 2a1b3043..6d502bc3 100644 --- a/lib/bcoin/chainentry.js +++ b/lib/bcoin/chainentry.js @@ -451,8 +451,8 @@ ChainEntry.fromRaw = function fromRaw(chain, buf) { ChainEntry.prototype.toJSON = function toJSON() { return { - version: this.version, hash: utils.revHex(this.hash), + version: this.version, prevBlock: utils.revHex(this.prevBlock), merkleRoot: utils.revHex(this.merkleRoot), ts: this.ts, @@ -471,11 +471,17 @@ ChainEntry.prototype.toJSON = function toJSON() { */ ChainEntry.fromJSON = function fromJSON(chain, json) { - json.hash = utils.revHex(json.hash); - json.prevBlock = utils.revHex(json.prevBlock); - json.merkleRoot = utils.revHex(json.merkleRoot); - json.chainwork = new bn(json.chainwork, 10); - return new ChainEntry(chain, json); + return new ChainEntry(chain, { + hash: utils.revHex(json.hash), + version: json.version, + prevBlock: utils.revHex(json.prevBlock), + merkleRoot: utils.revHex(json.merkleRoot), + ts: json.ts, + bits: json.bits, + nonce: json.nonce, + height: json.height, + chainwork: new bn(json.chainwork, 10) + }); }; /**