refactor: have promises resolve to undefined.

This commit is contained in:
Christopher Jeffrey 2016-10-09 23:52:52 -07:00
parent 0802dbbb0f
commit a2d6ed56e7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
11 changed files with 36 additions and 36 deletions

View File

@ -542,7 +542,7 @@ CLI.prototype.destroy = function destroy() {
this.wallet.client.destroy();
if (this.client && !this.client.loading)
this.client.destroy();
return Promise.resolve(null);
return Promise.resolve();
};
main = co(function* main() {

View File

@ -911,7 +911,7 @@ ChainDB.prototype.getTX = co(function* getTX(hash) {
ChainDB.prototype.hasTX = function hasTX(hash) {
if (!this.options.indexTX)
return Promise.resolve(null);
return Promise.resolve();
return this.db.has(layout.t(hash));
};

View File

@ -140,12 +140,12 @@ HTTPClient.prototype._sendAuth = function _sendAuth() {
HTTPClient.prototype._close = function close() {
if (!this.socket)
return Promise.resolve(null);
return Promise.resolve();
this.socket.disconnect();
this.socket = null;
return Promise.resolve(null);
return Promise.resolve();
};
/**
@ -384,7 +384,7 @@ HTTPClient.prototype.join = function join(id, token) {
var self = this;
if (!this.socket)
return Promise.resolve(null);
return Promise.resolve();
return new Promise(function(resolve, reject) {
self.socket.emit('wallet join', id, token, function(err) {
@ -404,7 +404,7 @@ HTTPClient.prototype.leave = function leave(id) {
var self = this;
if (!this.socket)
return Promise.resolve(null);
return Promise.resolve();
return new Promise(function(resolve, reject) {
self.socket.emit('wallet leave', id, function(err) {

View File

@ -417,7 +417,7 @@ RPC.prototype.addnode = function addnode(args) {
break;
}
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.disconnectnode = function disconnectnode(args) {
@ -433,7 +433,7 @@ RPC.prototype.disconnectnode = function disconnectnode(args) {
if (peer)
peer.destroy();
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.getaddednodeinfo = function getaddednodeinfo(args) {
@ -546,7 +546,7 @@ RPC.prototype.ping = function ping(args) {
for (i = 0; i < this.pool.peers.all.length; i++)
this.pool.peers.all[i].sendPing();
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.setban = function setban(args) {
@ -571,7 +571,7 @@ RPC.prototype.setban = function setban(args) {
break;
}
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.listbanned = function listbanned(args) {
@ -603,7 +603,7 @@ RPC.prototype.clearbanned = function clearbanned(args) {
this.pool.hosts.clear();
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype._deployment = function _deployment(id, version, status) {
@ -2199,7 +2199,7 @@ RPC.prototype.signrawtransaction = co(function* signrawtransaction(args) {
RPC.prototype._fillCoins = function _fillCoins(tx) {
if (this.chain.db.options.spv)
return Promise.resolve(null);
return Promise.resolve();
return this.node.fillCoins(tx);
};
@ -2645,7 +2645,7 @@ RPC.prototype.invalidateblock = function invalidateblock(args) {
this.chain.invalid[hash] = true;
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.reconsiderblock = function reconsiderblock(args) {
@ -2661,7 +2661,7 @@ RPC.prototype.reconsiderblock = function reconsiderblock(args) {
delete this.chain.invalid[hash];
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.setmocktime = function setmocktime(args) {
@ -2678,7 +2678,7 @@ RPC.prototype.setmocktime = function setmocktime(args) {
delta = time.now() - time;
time.offset = -delta;
return Promise.resolve(null);
return Promise.resolve();
};
/*
@ -3313,7 +3313,7 @@ RPC.prototype.importpubkey = co(function* importpubkey(args) {
RPC.prototype.keypoolrefill = function keypoolrefill(args) {
if (args.help || args.length > 1)
return Promise.reject(new RPCError('keypoolrefill ( newsize )'));
return Promise.resolve(null);
return Promise.resolve();
};
RPC.prototype.listaccounts = co(function* listaccounts(args) {

View File

@ -1579,7 +1579,7 @@ ClientSocket.prototype.scanner = function scanner(entry, txs) {
this.emit('block tx', entry.toJSON(), json);
return Promise.resolve(null);
return Promise.resolve();
};
ClientSocket.prototype.join = function join(id) {

View File

@ -137,7 +137,7 @@ Mempool.prototype._open = co(function* open() {
*/
Mempool.prototype._close = function close() {
return Promise.resolve(null);
return Promise.resolve();
};
/**

View File

@ -655,7 +655,7 @@ Peer.prototype.sendPing = function sendPing() {
if (this.challenge) {
this.logger.debug('Peer has not responded to ping (%s).', this.hostname);
return Promise.resolve(null);
return Promise.resolve();
}
this.lastPing = utils.ms();
@ -692,7 +692,7 @@ Peer.prototype.isWatched = function isWatched(item) {
Peer.prototype.updateWatch = function updateWatch() {
if (!this.options.spv)
return Promise.resolve(null);
return Promise.resolve();
return this.send(new packets.FilterLoadPacket(this.pool.spvFilter));
};
@ -768,7 +768,7 @@ Peer.prototype.write = function write(data) {
var self = this;
if (this.destroyed)
return Promise.resolve(null);
return Promise.resolve();
this.lastSend = utils.ms();
@ -778,7 +778,7 @@ Peer.prototype.write = function write(data) {
});
}
return Promise.resolve(null);
return Promise.resolve();
};
/**
@ -2254,7 +2254,7 @@ Peer.prototype._handleBlockTxn = function _handleBlockTxn(packet) {
Peer.prototype.sendAlert = function sendAlert(alert) {
if (!this.invFilter.added(alert.hash()))
return Promise.resolve(null);
return Promise.resolve();
return this.send(alert);
};
@ -2322,13 +2322,13 @@ Peer.prototype.sendGetBlocks = function getBlocks(locator, stop) {
Peer.prototype.sendMempool = function sendMempool() {
if (!this.version)
return Promise.resolve(null);
return Promise.resolve();
if (!this.version.hasBloom()) {
this.logger.debug(
'Cannot request mempool for non-bloom peer (%s).',
this.hostname);
return Promise.resolve(null);
return Promise.resolve();
}
this.logger.debug(
@ -2481,20 +2481,20 @@ Peer.prototype.sync = function sync() {
var tip;
if (!this.pool.syncing)
return Promise.resolve(null);
return Promise.resolve();
if (!this.ack)
return Promise.resolve(null);
return Promise.resolve();
if (this.syncSent)
return Promise.resolve(null);
return Promise.resolve();
if (!this.version.hasNetwork())
return Promise.resolve(null);
return Promise.resolve();
if (!this.isLoader()) {
if (!this.chain.synced)
return Promise.resolve(null);
return Promise.resolve();
}
// Ask for the mempool if we're synced.

View File

@ -418,7 +418,7 @@ Fullnode.prototype.getCoin = function getCoin(hash, index) {
return Promise.resolve(coin);
if (this.mempool.isSpent(hash, index))
return Promise.resolve(null);
return Promise.resolve();
return this.chain.db.getCoin(hash, index);
};

View File

@ -158,7 +158,7 @@ Locker.prototype.onDrain = function onDrain() {
assert(this.add, 'Cannot wait for drain without add method.');
if (this.pending.length === 0)
return Promise.resolve(null);
return Promise.resolve();
return new Promise(function(resolve, reject) {
self.once('drain', resolve);

View File

@ -244,10 +244,10 @@ Account.prototype.init = co(function* init() {
Account.prototype.open = function open() {
if (!this.initialized)
return Promise.resolve(null);
return Promise.resolve();
if (this.receive)
return Promise.resolve(null);
return Promise.resolve();
this.receive = this.deriveReceive(this.receiveDepth - 1);
this.change = this.deriveChange(this.changeDepth - 1);
@ -255,7 +255,7 @@ Account.prototype.open = function open() {
if (this.witness)
this.nested = this.deriveNested(this.nestedDepth - 1);
return Promise.resolve(null);
return Promise.resolve();
};
/**

View File

@ -241,7 +241,7 @@ describe('Chain', function() {
yield chain.db.scan(null, hashes, function(block, txs) {
total += txs.length;
return Promise.resolve(null);
return Promise.resolve();
});
assert.equal(total, 25);