refactor: misc.

This commit is contained in:
Christopher Jeffrey 2016-09-29 15:18:43 -07:00
parent f2c6bced5a
commit a467b4e475
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 9 additions and 15 deletions

View File

@ -148,7 +148,6 @@ if (utils.isBrowser)
* @param {String?} options.location - Database location
* @param {String?} options.db - Database backend name
* @property {Boolean} prune
* @property {Boolean} loaded
* @property {Number} keepBlocks
* @emits ChainDB#open
* @emits ChainDB#error
@ -181,8 +180,6 @@ function ChainDB(chain) {
this.pending = null;
this.current = null;
this.loaded = false;
// We want at least 1 retarget interval cached
// for retargetting, but we need at least two
// cached for optimal versionbits state checks.
@ -1368,12 +1365,11 @@ ChainDB.prototype.getFullTX = co(function* getFullTX(hash) {
ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) {
var block = yield this.getBlock(hash);
var view;
if (!block)
return;
view = yield this.getUndoView(block);
yield this.getUndoView(block);
return block;
});

View File

@ -366,7 +366,7 @@ Peer.prototype._bip150 = co(function* _bip150() {
if (this.bip150.outbound) {
if (!this.bip150.peerIdentity)
return this.error('No known identity for peer.');
throw new Error('No known identity for peer.');
this.send(this.bip150.toChallenge());
}
@ -2315,9 +2315,8 @@ Peer.prototype.sendReject = function sendReject(code, reason, obj) {
*/
Peer.prototype.sendCompact = function sendCompact() {
var cmpct = new packets.SendCmpctPacket(0, 1);
this.logger.info('Initializing compact blocks (%s).', this.hostname);
this.send(cmpct);
this.send(new packets.SendCmpctPacket(0, 1));
};
/**

View File

@ -2496,7 +2496,7 @@ BroadcastItem.prototype.start = function start() {
BroadcastItem.prototype.refresh = function refresh() {
var self = this;
if (this.timeout) {
if (this.timeout != null) {
clearTimeout(this.timeout);
this.timeout = null;
}

View File

@ -1025,9 +1025,8 @@ WalletDB.prototype.getPendingKeys = function getPendingKeys() {
*/
WalletDB.prototype.resend = co(function* resend() {
var i, keys, key, data, tx;
keys = yield this.getPendingKeys();
var keys = yield this.getPendingKeys();
var i, key, data, tx;
if (keys.length > 0)
this.logger.info('Rebroadcasting %d transactions.', keys.length);
@ -1094,7 +1093,7 @@ WalletDB.prototype.getPathInfo = co(function* getPathInfo(wallet, tx) {
WalletDB.prototype.getTable = co(function* getTable(hashes) {
var table = {};
var count = 0;
var match = false;
var i, j, keys, values, hash, paths;
for (i = 0; i < hashes.length; i++) {
@ -1115,10 +1114,10 @@ WalletDB.prototype.getTable = co(function* getTable(hashes) {
assert(!table[hash]);
table[hash] = values;
count += values.length;
match = true;
}
if (count === 0)
if (!match)
return;
return table;