From 93d2c8811f7e7ed775d96e9d3449e84a3c2b0be2 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 7 Nov 2016 14:11:17 -0800 Subject: [PATCH] walletdb: switch to u32s to potentially avoid deserialization. --- lib/wallet/records.js | 8 ++++---- lib/wallet/txdb.js | 4 ++-- migrate/walletdb5to6.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/wallet/records.js b/lib/wallet/records.js index 83a693dd..df5cf7f6 100644 --- a/lib/wallet/records.js +++ b/lib/wallet/records.js @@ -244,7 +244,7 @@ function BlockMapRecord(height) { BlockMapRecord.prototype.fromRaw = function fromRaw(data) { var p = new BufferReader(data); - var count = p.readVarint(); + var count = p.readU32(); var i, hash, tx; for (i = 0; i < count; i++) { @@ -278,7 +278,7 @@ BlockMapRecord.prototype.toRaw = function toRaw(writer) { var p = new BufferWriter(writer); var i, tx; - p.writeVarint(this.txs.length); + p.writeU32(this.txs.length); for (i = 0; i < this.txs.length; i++) { tx = this.txs[i]; @@ -450,7 +450,7 @@ function cmpid(a, b) { function parseWallets(data) { var p = new BufferReader(data); - var count = p.readVarint(); + var count = p.readU32(); var wids = []; var i; @@ -464,7 +464,7 @@ function serializeWallets(wids, writer) { var p = new BufferWriter(writer); var i, wid; - p.writeVarint(wids.length); + p.writeU32(wids.length); for (i = 0; i < wids.length; i++) { wid = wids[i]; diff --git a/lib/wallet/txdb.js b/lib/wallet/txdb.js index 8874c1e4..7f46401d 100644 --- a/lib/wallet/txdb.js +++ b/lib/wallet/txdb.js @@ -3442,7 +3442,7 @@ BlockRecord.prototype.fromRaw = function fromRaw(data) { this.height = p.readU32(); this.ts = p.readU32(); - count = p.readVarint(); + count = p.readU32(); for (i = 0; i < count; i++) { hash = p.readHash('hex'); @@ -3477,7 +3477,7 @@ BlockRecord.prototype.toRaw = function toRaw(writer) { p.writeU32(this.height); p.writeU32(this.ts); - p.writeVarint(this.hashes.length); + p.writeU32(this.hashes.length); for (i = 0; i < this.hashes.length; i++) p.writeHash(this.hashes[i]); diff --git a/migrate/walletdb5to6.js b/migrate/walletdb5to6.js index e0a3c552..9d688b30 100644 --- a/migrate/walletdb5to6.js +++ b/migrate/walletdb5to6.js @@ -143,7 +143,7 @@ function serializeWallets(wids, writer) { var p = new BufferWriter(writer); var i, wid; - p.writeVarint(wids.length); + p.writeU32(wids.length); for (i = 0; i < wids.length; i++) { wid = wids[i];