refactor: lint. misc.

This commit is contained in:
Christopher Jeffrey 2016-09-23 00:56:53 -07:00
parent 9bbd8de8bf
commit 3b14525d17
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
6 changed files with 29 additions and 11 deletions

View File

@ -1520,7 +1520,7 @@ ChainDB.prototype.hasCoins = function hasCoins(hash) {
*/
ChainDB.prototype.pruneBlock = co(function* pruneBlock(block) {
var futureHeight, key, hash, data;
var futureHeight, key, hash;
if (this.options.spv)
return;

View File

@ -8,6 +8,7 @@
var bcoin = require('../env');
var utils = require('../utils/utils');
var spawn = require('../utils/spawn');
var crypto = require('../crypto/crypto');
var assert = utils.assert;
var constants = bcoin.constants;
@ -363,7 +364,7 @@ CompactBlock.fromBlock = function fromBlock(block, nonce) {
return new CompactBlock().fromBlock(block, nonce);
};
CompactBlock.prototype.wait = function wait(callback) {
CompactBlock.prototype.wait = function wait(time) {
var self = this;
return new Promise(function(resolve, reject) {
self._wait(time, spawn.wrap(resolve, reject));

View File

@ -466,6 +466,8 @@ Peer.prototype._finalize = co(function* _finalize() {
// Start syncing the chain.
this.sync();
yield spawn.wait();
});
/**
@ -1347,8 +1349,6 @@ Peer.prototype.__handleGetBlocks = co(function* _handleGetBlocks(packet) {
*/
Peer.prototype._handleVersion = co(function* _handleVersion(version) {
var self = this;
if (!this.network.selfConnect) {
if (version.nonce.cmp(this.pool.localNonce) === 0) {
this.error('We connected to ourself. Oops.');
@ -2128,13 +2128,13 @@ Peer.prototype._handleGetBlockTxn = co(function* _handleGetBlockTxn(packet) {
var res, item, block;
if (this.chain.db.options.spv)
return done();
return;
if (this.chain.db.options.prune)
return done();
return;
if (this.options.selfish)
return done();
return;
item = new InvItem(constants.inv.BLOCK, req.hash);

View File

@ -721,6 +721,15 @@ Pool.prototype._handleHeaders = co(function* _handleHeaders(headers, peer) {
}
});
/**
* Handle `headers` packet from
* a given peer without a lock.
* @private
* @param {Headers[]} headers
* @param {Peer} peer
* @param {Function} callback
*/
Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) {
var i, ret, header, hash, last;
@ -773,7 +782,7 @@ Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) {
// simply tries to find the latest block in
// the peer's chain.
if (last && headers.length === 2000)
yield peer.getHeaders(last, null);
yield peer.getHeaders(last);
});
/**
@ -861,6 +870,14 @@ Pool.prototype._handleInv = co(function* _handleInv(hashes, peer) {
}
});
/**
* Handle `inv` packet from peer without a lock.
* @private
* @param {Hash[]} hashes
* @param {Peer} peer
* @param {Function} callback
*/
Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
var i, hash;
@ -1060,7 +1077,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
try {
yield self._handleBlock(block, peer);
} catch (e) {
self.emit('error', err);
self.emit('error', e);
return;
}

View File

@ -1311,7 +1311,7 @@ WalletDB.prototype._addBlock = co(function* addBlock(entry, txs) {
WalletDB.prototype.removeBlock = co(function* removeBlock(entry) {
var unlock = yield this.txLock.lock();
try {
return yield this._removeBlock(entry, txs);
return yield this._removeBlock(entry);
} finally {
unlock();
}

View File

@ -217,7 +217,7 @@ describe('Chain', function() {
assert.ifError(err);
// assert.equal(balance.unconfirmed, 23000000000);
// assert.equal(balance.confirmed, 97000000000);
// assert.equal(balance.total, 120000000000);
assert.equal(balance.total, 120000000000);
// assert.equal(wallet.account.receiveDepth, 8);
// assert.equal(wallet.account.changeDepth, 7);
assert.equal(walletdb.height, chain.height);