rpc: misc fixes.

This commit is contained in:
Christopher Jeffrey 2017-03-10 06:04:24 -08:00
parent 48066f1634
commit b453898f6e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 11 additions and 21 deletions

View File

@ -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;

View File

@ -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();