wallet/mempool: lint. spvnode.

This commit is contained in:
Christopher Jeffrey 2016-08-17 04:57:02 -07:00
parent 2fdfdd3c8a
commit 197e9f7aa9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 25 additions and 16 deletions

View File

@ -718,7 +718,7 @@ Mempool.prototype.removeUnchecked = function removeUnchecked(entry, limit) {
// now exist on the blockchain). // now exist on the blockchain).
if (limit) { if (limit) {
this._removeSpenders(entry); this._removeSpenders(entry);
this.logger.debug('Evicting %s from the mempool.', tx.rhash); this.logger.debug('Evicting %s from the mempool.', entry.tx.rhash);
} }
this.untrackEntry(entry); this.untrackEntry(entry);
@ -1485,7 +1485,7 @@ Mempool.prototype._removeSpenders = function _removeSpenders(entry) {
Mempool.prototype.memUsage = function memUsage(tx) { Mempool.prototype.memUsage = function memUsage(tx) {
var mem = 0; var mem = 0;
var i, j, input, output; var i, input, output;
mem += 264; // tx mem += 264; // tx
mem += 80; // _hash mem += 80; // _hash

View File

@ -198,7 +198,7 @@ SPVNode.prototype._open = function open(callback) {
}, },
function(next) { function(next) {
var i; var i;
self.walletdb.getAddresses(function(err, hashes) { self.walletdb.getAddressHashes(function(err, hashes) {
if (err) if (err)
return next(err); return next(err);

View File

@ -1407,7 +1407,7 @@ TXDB.prototype.filterLocked = function filterLocked(coins) {
TXDB.prototype.getLocked = function getLocked() { TXDB.prototype.getLocked = function getLocked() {
var keys = Object.keys(this.locked); var keys = Object.keys(this.locked);
var outpoints = []; var outpoints = [];
var i, key, hash, index; var i, key, hash, index, outpoint;
for (i = 0; i < keys.length; i++) { for (i = 0; i < keys.length; i++) {
key = keys[i]; key = keys[i];

View File

@ -568,8 +568,8 @@ Wallet.prototype.getAccounts = function getAccounts(callback) {
* @param {Function} callback - Returns [Error, Array]. * @param {Function} callback - Returns [Error, Array].
*/ */
Wallet.prototype.getAddresses = function getAddresses(callback) { Wallet.prototype.getAddressHashes = function getAddressHashes(callback) {
this.db.getAddresses(this.wid, callback); this.db.getAddressHashes(this.wid, callback);
}; };
/** /**
@ -724,23 +724,31 @@ Wallet.prototype.commit = function commit(callback) {
/** /**
* Test whether the wallet possesses an address. * Test whether the wallet possesses an address.
* @param {Base58Address} address * @param {Address|Hash} address
* @param {Function} callback - Returns [Error, Boolean]. * @param {Function} callback - Returns [Error, Boolean].
*/ */
Wallet.prototype.hasAddress = function hasAddress(address, callback) { Wallet.prototype.hasAddress = function hasAddress(address, callback) {
return this.db.hasAddress(this.wid, address, callback); var hash = bcoin.address.getHash(address, 'hex');
if (!hash)
return callback(null, false);
return this.db.hasAddress(this.wid, hash, callback);
}; };
/** /**
* Get path by address hash. * Get path by address hash.
* @param {Hash} address * @param {Address|Hash} address
* @param {Function} callback - Returns [Error, {@link Path}]. * @param {Function} callback - Returns [Error, {@link Path}].
*/ */
Wallet.prototype.getAddressPath = function getAddressPath(address, callback) { Wallet.prototype.getAddressPath = function getAddressPath(address, callback) {
var self = this; var self = this;
this.db.getAddressPath(this.wid, address, function(err, path) { var hash = bcoin.address.getHash(address, 'hex');
if (!hash)
return callback();
this.db.getAddressPath(this.wid, hash, function(err, path) {
if (err) if (err)
return callback(err); return callback(err);
@ -755,7 +763,7 @@ Wallet.prototype.getAddressPath = function getAddressPath(address, callback) {
/** /**
* Get all wallet paths. * Get all wallet paths.
* @param {Number} account * @param {(String|Number)?} account
* @param {Function} callback - Returns [Error, {@link Path}]. * @param {Function} callback - Returns [Error, {@link Path}].
*/ */
@ -1052,13 +1060,14 @@ Wallet.prototype.deriveInputs = function deriveInputs(tx, callback) {
}; };
/** /**
* Retrieve a single keyring by address hash. * Retrieve a single keyring by address.
* @param {Hash} hash * @param {Address|Hash} hash
* @param {Function} callback * @param {Function} callback
*/ */
Wallet.prototype.getKeyring = function getKeyring(hash, callback) { Wallet.prototype.getKeyring = function getKeyring(address, callback) {
var self = this; var self = this;
var hash = bcoin.address.getHash(address, 'hex');
var address; var address;
if (!hash) if (!hash)

View File

@ -1017,7 +1017,7 @@ WalletDB.prototype.hasAddress = function hasAddress(wid, address, callback) {
* @param {Function} callback * @param {Function} callback
*/ */
WalletDB.prototype.getAddresses = function getAddresses(wid, callback) { WalletDB.prototype.getAddressHashes = function getAddressHashes(wid, callback) {
if (!callback) { if (!callback) {
callback = wid; callback = wid;
wid = null; wid = null;
@ -1088,7 +1088,7 @@ WalletDB.prototype.getWallets = function getWallets(callback) {
WalletDB.prototype.rescan = function rescan(chaindb, callback) { WalletDB.prototype.rescan = function rescan(chaindb, callback) {
var self = this; var self = this;
this.getAddresses(function(err, hashes) { this.getAddressHashes(function(err, hashes) {
if (err) if (err)
return callback(err); return callback(err);