From 8d5bd36ac70706c57abad7d146c2203369b9220a Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 9 Sep 2016 12:56:06 -0700 Subject: [PATCH] walletdb: cleanup. --- lib/miner/miner.js | 2 - lib/wallet/walletdb.js | 115 +++++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 57 deletions(-) diff --git a/lib/miner/miner.js b/lib/miner/miner.js index b8e62640..92b73af2 100644 --- a/lib/miner/miner.js +++ b/lib/miner/miner.js @@ -327,8 +327,6 @@ Miner.prototype.mineBlock = function mineBlock(tip, callback) { }); }; -Miner.MinerBlock = MinerBlock; - /* * Expose */ diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index 74b9e991..b434781c 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -1641,6 +1641,7 @@ WalletDB.prototype.getAddressPath = function getAddressPath(wid, hash, callback) /** * Path Info + * @constructor */ function PathInfo(db, wid, tx, table) { @@ -1805,6 +1806,7 @@ PathInfo.prototype.toJSON = function toJSON() { /** * Details + * @constructor */ function Details(info) { @@ -1894,6 +1896,7 @@ Details.prototype.toJSON = function toJSON() { /** * DetailsMember + * @constructor */ function DetailsMember() { @@ -1917,59 +1920,11 @@ DetailsMember.prototype.toJSON = function toJSON(network) { }; }; -/* - * Helpers +/** + * Wallet Block + * @constructor */ -function parsePaths(data, hash) { - var p = new BufferReader(data); - var out = {}; - var path; - - while (p.left()) { - path = Path.fromRaw(p); - out[path.wid] = path; - if (hash) - path.hash = hash; - } - - return out; -} - -function serializePaths(out) { - var p = new BufferWriter(); - var keys = Object.keys(out); - var i, wid, path; - - for (i = 0; i < keys.length; i++) { - wid = keys[i]; - path = out[wid]; - path.toRaw(p); - } - - return p.render(); -} - -function parseWallets(data) { - var p = new BufferReader(data); - var wallets = []; - while (p.left()) - wallets.push(p.readU32()); - return wallets; -} - -function serializeWallets(wallets) { - var p = new BufferWriter(); - var i, info; - - for (i = 0; i < wallets.length; i++) { - info = wallets[i]; - p.writeU32(info.wid); - } - - return p.render(); -} - function WalletBlock(hash, height) { if (!(this instanceof WalletBlock)) return new WalletBlock(hash, height); @@ -2053,11 +2008,61 @@ WalletBlock.prototype.toJSON = function toJSON() { }; }; +/* + * Helpers + */ + +function parsePaths(data, hash) { + var p = new BufferReader(data); + var out = {}; + var path; + + while (p.left()) { + path = Path.fromRaw(p); + out[path.wid] = path; + if (hash) + path.hash = hash; + } + + return out; +} + +function serializePaths(out) { + var p = new BufferWriter(); + var keys = Object.keys(out); + var i, wid, path; + + for (i = 0; i < keys.length; i++) { + wid = keys[i]; + path = out[wid]; + path.toRaw(p); + } + + return p.render(); +} + +function parseWallets(data) { + var p = new BufferReader(data); + var wallets = []; + while (p.left()) + wallets.push(p.readU32()); + return wallets; +} + +function serializeWallets(wallets) { + var p = new BufferWriter(); + var i, info; + + for (i = 0; i < wallets.length; i++) { + info = wallets[i]; + p.writeU32(info.wid); + } + + return p.render(); +} + /* * Expose */ -exports = WalletDB; -exports.Path = Path; - -module.exports = exports; +module.exports = WalletDB;