refactor: have promises resolve to undefined.
This commit is contained in:
parent
0802dbbb0f
commit
a2d6ed56e7
2
bin/cli
2
bin/cli
@ -542,7 +542,7 @@ CLI.prototype.destroy = function destroy() {
|
|||||||
this.wallet.client.destroy();
|
this.wallet.client.destroy();
|
||||||
if (this.client && !this.client.loading)
|
if (this.client && !this.client.loading)
|
||||||
this.client.destroy();
|
this.client.destroy();
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
main = co(function* main() {
|
main = co(function* main() {
|
||||||
|
|||||||
@ -911,7 +911,7 @@ ChainDB.prototype.getTX = co(function* getTX(hash) {
|
|||||||
|
|
||||||
ChainDB.prototype.hasTX = function hasTX(hash) {
|
ChainDB.prototype.hasTX = function hasTX(hash) {
|
||||||
if (!this.options.indexTX)
|
if (!this.options.indexTX)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return this.db.has(layout.t(hash));
|
return this.db.has(layout.t(hash));
|
||||||
};
|
};
|
||||||
|
|||||||
@ -140,12 +140,12 @@ HTTPClient.prototype._sendAuth = function _sendAuth() {
|
|||||||
|
|
||||||
HTTPClient.prototype._close = function close() {
|
HTTPClient.prototype._close = function close() {
|
||||||
if (!this.socket)
|
if (!this.socket)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
this.socket.disconnect();
|
this.socket.disconnect();
|
||||||
this.socket = null;
|
this.socket = null;
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,7 +384,7 @@ HTTPClient.prototype.join = function join(id, token) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!this.socket)
|
if (!this.socket)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
self.socket.emit('wallet join', id, token, function(err) {
|
self.socket.emit('wallet join', id, token, function(err) {
|
||||||
@ -404,7 +404,7 @@ HTTPClient.prototype.leave = function leave(id) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!this.socket)
|
if (!this.socket)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
self.socket.emit('wallet leave', id, function(err) {
|
self.socket.emit('wallet leave', id, function(err) {
|
||||||
|
|||||||
@ -417,7 +417,7 @@ RPC.prototype.addnode = function addnode(args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.disconnectnode = function disconnectnode(args) {
|
RPC.prototype.disconnectnode = function disconnectnode(args) {
|
||||||
@ -433,7 +433,7 @@ RPC.prototype.disconnectnode = function disconnectnode(args) {
|
|||||||
if (peer)
|
if (peer)
|
||||||
peer.destroy();
|
peer.destroy();
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.getaddednodeinfo = function getaddednodeinfo(args) {
|
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++)
|
for (i = 0; i < this.pool.peers.all.length; i++)
|
||||||
this.pool.peers.all[i].sendPing();
|
this.pool.peers.all[i].sendPing();
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.setban = function setban(args) {
|
RPC.prototype.setban = function setban(args) {
|
||||||
@ -571,7 +571,7 @@ RPC.prototype.setban = function setban(args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.listbanned = function listbanned(args) {
|
RPC.prototype.listbanned = function listbanned(args) {
|
||||||
@ -603,7 +603,7 @@ RPC.prototype.clearbanned = function clearbanned(args) {
|
|||||||
|
|
||||||
this.pool.hosts.clear();
|
this.pool.hosts.clear();
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype._deployment = function _deployment(id, version, status) {
|
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) {
|
RPC.prototype._fillCoins = function _fillCoins(tx) {
|
||||||
if (this.chain.db.options.spv)
|
if (this.chain.db.options.spv)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return this.node.fillCoins(tx);
|
return this.node.fillCoins(tx);
|
||||||
};
|
};
|
||||||
@ -2645,7 +2645,7 @@ RPC.prototype.invalidateblock = function invalidateblock(args) {
|
|||||||
|
|
||||||
this.chain.invalid[hash] = true;
|
this.chain.invalid[hash] = true;
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.reconsiderblock = function reconsiderblock(args) {
|
RPC.prototype.reconsiderblock = function reconsiderblock(args) {
|
||||||
@ -2661,7 +2661,7 @@ RPC.prototype.reconsiderblock = function reconsiderblock(args) {
|
|||||||
|
|
||||||
delete this.chain.invalid[hash];
|
delete this.chain.invalid[hash];
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.setmocktime = function setmocktime(args) {
|
RPC.prototype.setmocktime = function setmocktime(args) {
|
||||||
@ -2678,7 +2678,7 @@ RPC.prototype.setmocktime = function setmocktime(args) {
|
|||||||
delta = time.now() - time;
|
delta = time.now() - time;
|
||||||
time.offset = -delta;
|
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) {
|
RPC.prototype.keypoolrefill = function keypoolrefill(args) {
|
||||||
if (args.help || args.length > 1)
|
if (args.help || args.length > 1)
|
||||||
return Promise.reject(new RPCError('keypoolrefill ( newsize )'));
|
return Promise.reject(new RPCError('keypoolrefill ( newsize )'));
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.listaccounts = co(function* listaccounts(args) {
|
RPC.prototype.listaccounts = co(function* listaccounts(args) {
|
||||||
|
|||||||
@ -1579,7 +1579,7 @@ ClientSocket.prototype.scanner = function scanner(entry, txs) {
|
|||||||
|
|
||||||
this.emit('block tx', entry.toJSON(), json);
|
this.emit('block tx', entry.toJSON(), json);
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientSocket.prototype.join = function join(id) {
|
ClientSocket.prototype.join = function join(id) {
|
||||||
|
|||||||
@ -137,7 +137,7 @@ Mempool.prototype._open = co(function* open() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Mempool.prototype._close = function close() {
|
Mempool.prototype._close = function close() {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -655,7 +655,7 @@ Peer.prototype.sendPing = function sendPing() {
|
|||||||
|
|
||||||
if (this.challenge) {
|
if (this.challenge) {
|
||||||
this.logger.debug('Peer has not responded to ping (%s).', this.hostname);
|
this.logger.debug('Peer has not responded to ping (%s).', this.hostname);
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastPing = utils.ms();
|
this.lastPing = utils.ms();
|
||||||
@ -692,7 +692,7 @@ Peer.prototype.isWatched = function isWatched(item) {
|
|||||||
|
|
||||||
Peer.prototype.updateWatch = function updateWatch() {
|
Peer.prototype.updateWatch = function updateWatch() {
|
||||||
if (!this.options.spv)
|
if (!this.options.spv)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return this.send(new packets.FilterLoadPacket(this.pool.spvFilter));
|
return this.send(new packets.FilterLoadPacket(this.pool.spvFilter));
|
||||||
};
|
};
|
||||||
@ -768,7 +768,7 @@ Peer.prototype.write = function write(data) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this.destroyed)
|
if (this.destroyed)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
this.lastSend = utils.ms();
|
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) {
|
Peer.prototype.sendAlert = function sendAlert(alert) {
|
||||||
if (!this.invFilter.added(alert.hash()))
|
if (!this.invFilter.added(alert.hash()))
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return this.send(alert);
|
return this.send(alert);
|
||||||
};
|
};
|
||||||
@ -2322,13 +2322,13 @@ Peer.prototype.sendGetBlocks = function getBlocks(locator, stop) {
|
|||||||
|
|
||||||
Peer.prototype.sendMempool = function sendMempool() {
|
Peer.prototype.sendMempool = function sendMempool() {
|
||||||
if (!this.version)
|
if (!this.version)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (!this.version.hasBloom()) {
|
if (!this.version.hasBloom()) {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
'Cannot request mempool for non-bloom peer (%s).',
|
'Cannot request mempool for non-bloom peer (%s).',
|
||||||
this.hostname);
|
this.hostname);
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
@ -2481,20 +2481,20 @@ Peer.prototype.sync = function sync() {
|
|||||||
var tip;
|
var tip;
|
||||||
|
|
||||||
if (!this.pool.syncing)
|
if (!this.pool.syncing)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (!this.ack)
|
if (!this.ack)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (this.syncSent)
|
if (this.syncSent)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (!this.version.hasNetwork())
|
if (!this.version.hasNetwork())
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (!this.isLoader()) {
|
if (!this.isLoader()) {
|
||||||
if (!this.chain.synced)
|
if (!this.chain.synced)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask for the mempool if we're synced.
|
// Ask for the mempool if we're synced.
|
||||||
|
|||||||
@ -418,7 +418,7 @@ Fullnode.prototype.getCoin = function getCoin(hash, index) {
|
|||||||
return Promise.resolve(coin);
|
return Promise.resolve(coin);
|
||||||
|
|
||||||
if (this.mempool.isSpent(hash, index))
|
if (this.mempool.isSpent(hash, index))
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return this.chain.db.getCoin(hash, index);
|
return this.chain.db.getCoin(hash, index);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -158,7 +158,7 @@ Locker.prototype.onDrain = function onDrain() {
|
|||||||
assert(this.add, 'Cannot wait for drain without add method.');
|
assert(this.add, 'Cannot wait for drain without add method.');
|
||||||
|
|
||||||
if (this.pending.length === 0)
|
if (this.pending.length === 0)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
self.once('drain', resolve);
|
self.once('drain', resolve);
|
||||||
|
|||||||
@ -244,10 +244,10 @@ Account.prototype.init = co(function* init() {
|
|||||||
|
|
||||||
Account.prototype.open = function open() {
|
Account.prototype.open = function open() {
|
||||||
if (!this.initialized)
|
if (!this.initialized)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
if (this.receive)
|
if (this.receive)
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
|
|
||||||
this.receive = this.deriveReceive(this.receiveDepth - 1);
|
this.receive = this.deriveReceive(this.receiveDepth - 1);
|
||||||
this.change = this.deriveChange(this.changeDepth - 1);
|
this.change = this.deriveChange(this.changeDepth - 1);
|
||||||
@ -255,7 +255,7 @@ Account.prototype.open = function open() {
|
|||||||
if (this.witness)
|
if (this.witness)
|
||||||
this.nested = this.deriveNested(this.nestedDepth - 1);
|
this.nested = this.deriveNested(this.nestedDepth - 1);
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -241,7 +241,7 @@ describe('Chain', function() {
|
|||||||
|
|
||||||
yield chain.db.scan(null, hashes, function(block, txs) {
|
yield chain.db.scan(null, hashes, function(block, txs) {
|
||||||
total += txs.length;
|
total += txs.length;
|
||||||
return Promise.resolve(null);
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(total, 25);
|
assert.equal(total, 25);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user