node/rpc: throw errors on shutdown. minor changes.

This commit is contained in:
Christopher Jeffrey 2017-07-25 05:30:18 -07:00
parent 7eefb773be
commit 32c93af2c4
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 7 additions and 4 deletions

View File

@ -202,7 +202,11 @@ RPC.prototype.stop = async function stop(args, help) {
if (help || args.length !== 0)
throw new RPCError(errs.MISC_ERROR, 'stop');
this.node.close().catch(() => {});
this.node.close().catch((err) => {
setImmediate(() => {
throw err;
});
});
return 'Stopping.';
};

View File

@ -402,9 +402,8 @@ FullNode.prototype.getCoinsByAddress = async function getCoinsByAddress(addrs) {
let mempool = this.mempool.getCoinsByAddress(addrs);
let chain = await this.chain.db.getCoinsByAddress(addrs);
let out = [];
let coin;
for (coin of chain) {
for (let coin of chain) {
let spent = this.mempool.isSpent(coin.hash, coin.index);
if (spent)
@ -413,7 +412,7 @@ FullNode.prototype.getCoinsByAddress = async function getCoinsByAddress(addrs) {
out.push(coin);
}
for (coin of mempool)
for (let coin of mempool)
out.push(coin);
return out;