rpc: misc fixes.
This commit is contained in:
parent
48066f1634
commit
b453898f6e
@ -418,7 +418,7 @@ RPC.prototype.listBanned = co(function* listBanned(args, help) {
|
|||||||
time = this.pool.hosts.banned[host];
|
time = this.pool.hosts.banned[host];
|
||||||
banned.push({
|
banned.push({
|
||||||
address: host,
|
address: host,
|
||||||
banned_until: time + this.pool.hosts.banTime,
|
banned_until: time + this.pool.options.banTime,
|
||||||
ban_created: time,
|
ban_created: time,
|
||||||
ban_reason: ''
|
ban_reason: ''
|
||||||
});
|
});
|
||||||
@ -564,7 +564,7 @@ RPC.prototype.getChainTips = co(function* getChainTips(args, help) {
|
|||||||
entry = yield this.chain.db.getEntry(hash);
|
entry = yield this.chain.db.getEntry(hash);
|
||||||
assert(entry);
|
assert(entry);
|
||||||
|
|
||||||
fork = yield this._findFork(entry);
|
fork = yield this.findFork(entry);
|
||||||
main = yield entry.isMainChain();
|
main = yield entry.isMainChain();
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
@ -578,15 +578,6 @@ RPC.prototype.getChainTips = co(function* getChainTips(args, help) {
|
|||||||
return result;
|
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) {
|
RPC.prototype.getDifficulty = co(function* getDifficulty(args, help) {
|
||||||
if (help || args.length !== 0)
|
if (help || args.length !== 0)
|
||||||
throw new RPCError('getdifficulty');
|
throw new RPCError('getdifficulty');
|
||||||
@ -2326,6 +2317,15 @@ RPC.prototype.mineBlocks = co(function* mineBlocks(blocks, address, tries) {
|
|||||||
return hashes;
|
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) {
|
RPC.prototype.txToJSON = function txToJSON(tx, entry) {
|
||||||
var height = -1;
|
var height = -1;
|
||||||
var conf = 0;
|
var conf = 0;
|
||||||
|
|||||||
@ -154,16 +154,6 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
|||||||
this.logger.info('Successful auth for %s.', id);
|
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
|
// Rescan
|
||||||
this.post('/_admin/rescan', co(function* (req, res) {
|
this.post('/_admin/rescan', co(function* (req, res) {
|
||||||
var valid = req.valid();
|
var valid = req.valid();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user