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() {
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)
});
};
/**