From 32c93af2c41d34cdb53d77f6790578e67e911d74 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 25 Jul 2017 05:30:18 -0700 Subject: [PATCH] node/rpc: throw errors on shutdown. minor changes. --- lib/http/rpc.js | 6 +++++- lib/node/fullnode.js | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/http/rpc.js b/lib/http/rpc.js index 436fa316..9ae5db0f 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -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.'; }; diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js index d66cd5bb..1e236972 100644 --- a/lib/node/fullnode.js +++ b/lib/node/fullnode.js @@ -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;