chainentry json.

This commit is contained in:
Christopher Jeffrey 2016-06-02 18:52:23 -07:00
parent 33f7b38433
commit 819795b1ae
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -451,8 +451,8 @@ ChainEntry.fromRaw = function fromRaw(chain, buf) {
ChainEntry.prototype.toJSON = function toJSON() { ChainEntry.prototype.toJSON = function toJSON() {
return { return {
version: this.version,
hash: utils.revHex(this.hash), hash: utils.revHex(this.hash),
version: this.version,
prevBlock: utils.revHex(this.prevBlock), prevBlock: utils.revHex(this.prevBlock),
merkleRoot: utils.revHex(this.merkleRoot), merkleRoot: utils.revHex(this.merkleRoot),
ts: this.ts, ts: this.ts,
@ -471,11 +471,17 @@ ChainEntry.prototype.toJSON = function toJSON() {
*/ */
ChainEntry.fromJSON = function fromJSON(chain, json) { ChainEntry.fromJSON = function fromJSON(chain, json) {
json.hash = utils.revHex(json.hash); return new ChainEntry(chain, {
json.prevBlock = utils.revHex(json.prevBlock); hash: utils.revHex(json.hash),
json.merkleRoot = utils.revHex(json.merkleRoot); version: json.version,
json.chainwork = new bn(json.chainwork, 10); prevBlock: utils.revHex(json.prevBlock),
return new ChainEntry(chain, json); merkleRoot: utils.revHex(json.merkleRoot),
ts: json.ts,
bits: json.bits,
nonce: json.nonce,
height: json.height,
chainwork: new bn(json.chainwork, 10)
});
}; };
/** /**