walletdb: cleanup.

This commit is contained in:
Christopher Jeffrey 2016-09-09 12:56:06 -07:00
parent d82f061c83
commit 8d5bd36ac7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 60 additions and 57 deletions

View File

@ -327,8 +327,6 @@ Miner.prototype.mineBlock = function mineBlock(tip, callback) {
});
};
Miner.MinerBlock = MinerBlock;
/*
* Expose
*/

View File

@ -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;