rpc: implement more methods.

This commit is contained in:
Christopher Jeffrey 2016-07-31 16:27:41 -07:00
parent 666ff94ddf
commit 104458a483
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 1371 additions and 91 deletions

File diff suppressed because it is too large Load Diff

View File

@ -309,7 +309,10 @@ HTTPServer.prototype._init = function _init() {
res.setHeader('WWW-Authenticate', 'Basic realm="rpc"');
send(401, {
result: null,
error: 'Bad auth.',
error: {
message: 'Bad auth.',
code: 1
},
id: req.body.id
});
return;
@ -326,7 +329,10 @@ HTTPServer.prototype._init = function _init() {
self.logger.error(err);
return send(400, {
result: null,
error: err.message,
error: {
message: err.message,
code: 1
},
id: req.body.id
});
}

View File

@ -797,6 +797,13 @@ utils.inspectify = function inspectify(obj, color) {
: obj;
};
/**
* Format a string.
* @function
*/
utils.fmt = util.format;
/**
* Format a string.
* @param {Array} args

View File

@ -2481,6 +2481,7 @@ function MasterKey(options) {
this.key = null;
this.timer = null;
this.until = 0;
this._destroy = this.destroy.bind(this);
this.locker = new bcoin.locker(this);
}
@ -2585,6 +2586,7 @@ MasterKey.prototype.start = function start(timeout) {
if (timeout === -1)
return;
this.until = utils.now() + (timeout / 1000 | 0);
this.timer = setTimeout(this._destroy, timeout);
};
@ -2597,6 +2599,7 @@ MasterKey.prototype.stop = function stop() {
if (this.timer != null) {
clearTimeout(this.timer);
this.timer = null;
this.until = 0;
}
};