From b453898f6ed4e53879a9a4dc2f056ef53fc2ee7f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 10 Mar 2017 06:04:24 -0800 Subject: [PATCH] rpc: misc fixes. --- lib/http/rpc.js | 22 +++++++++++----------- lib/wallet/http.js | 10 ---------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/http/rpc.js b/lib/http/rpc.js index f7abed27..f9b2340f 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -418,7 +418,7 @@ RPC.prototype.listBanned = co(function* listBanned(args, help) { time = this.pool.hosts.banned[host]; banned.push({ address: host, - banned_until: time + this.pool.hosts.banTime, + banned_until: time + this.pool.options.banTime, ban_created: time, ban_reason: '' }); @@ -564,7 +564,7 @@ RPC.prototype.getChainTips = co(function* getChainTips(args, help) { entry = yield this.chain.db.getEntry(hash); assert(entry); - fork = yield this._findFork(entry); + fork = yield this.findFork(entry); main = yield entry.isMainChain(); result.push({ @@ -578,15 +578,6 @@ RPC.prototype.getChainTips = co(function* getChainTips(args, help) { return result; }); -RPC.prototype._findFork = co(function* _findFork(entry) { - while (entry) { - if (yield entry.isMainChain()) - return entry; - entry = yield entry.getPrevious(); - } - throw new Error('Fork not found.'); -}); - RPC.prototype.getDifficulty = co(function* getDifficulty(args, help) { if (help || args.length !== 0) throw new RPCError('getdifficulty'); @@ -2326,6 +2317,15 @@ RPC.prototype.mineBlocks = co(function* mineBlocks(blocks, address, tries) { return hashes; }); +RPC.prototype.findFork = co(function* findFork(entry) { + while (entry) { + if (yield entry.isMainChain()) + return entry; + entry = yield entry.getPrevious(); + } + throw new Error('Fork not found.'); +}); + RPC.prototype.txToJSON = function txToJSON(tx, entry) { var height = -1; var conf = 0; diff --git a/lib/wallet/http.js b/lib/wallet/http.js index 54e5366b..4ac641d7 100644 --- a/lib/wallet/http.js +++ b/lib/wallet/http.js @@ -154,16 +154,6 @@ HTTPServer.prototype.initRouter = function initRouter() { this.logger.info('Successful auth for %s.', id); })); - // JSON RPC - this.post('/', co(function* (req, res) { - var json = yield this.rpc.call(req.body, req.query); - - json = JSON.stringify(json); - json += '\n'; - - res.send(200, json, 'json'); - })); - // Rescan this.post('/_admin/rescan', co(function* (req, res) { var valid = req.valid();