wip new routes.

This commit is contained in:
k 2017-04-24 13:44:08 -04:00
parent 42c957d02a
commit 0788da0e45
3 changed files with 19 additions and 5 deletions

View File

@ -1171,8 +1171,8 @@ AddressService.prototype.getAddressTxidsWithHeights = function(address, options,
var opts = options || {};
var txids = {};
var start = self._encoding.encodeAddressIndexKey(address, opts.start || 0, '00');
var end = self._encoding.encodeAddressIndexKey(address, opts.end || 0xffffffff);
var start = self._encoding.encodeAddressIndexKey(address, opts.start || 0); //the start and end must be the same length
var end = Buffer.concat([ start.slice(0, -36), new Buffer((opts.end || 0xffffffff), 'hex') ]);
var stream = self.store.createKeyStream({
gte: start,

View File

@ -62,6 +62,7 @@ function DB(options) {
};
this._sync = new Sync(this.node, this);
this.syncing = true;
}
util.inherits(DB, Service);
@ -132,6 +133,7 @@ DB.prototype.start = function(callback) {
self.store = levelup(self.dataPath, { db: self.levelupStore, keyEncoding: 'binary', valueEncoding: 'binary'});
self._sync.on('error', function(err) {
self.syncing = false;
log.error(err);
});
@ -160,6 +162,7 @@ DB.prototype.start = function(callback) {
});
self._sync.on('synced', function() {
self.syncing = false;
log.info('Initial sync complete');
});

View File

@ -566,12 +566,10 @@ WalletService.prototype._endpointPostAddresses = function() {
if (!addresses || !addresses.length) {
return utils.sendError(new Error('addresses are required when creating a wallet.'), res);
}
var walletId = req.params.walletId; //also can't be zero
var walletId = req.params.walletId;
if (!walletId) {
return utils.sendError(new Error('WalletId must be given.'), res);
}
// TODO make imdempotent
//this could be a long-running operation, so we'll return a job id
if (!self._isJobQueueReady()) {
return utils.sendError(new Error('Job queue is currently overloaded, please try again later.'), res);
}
@ -1125,6 +1123,16 @@ WalletService.prototype._endpointJobs = function() {
};
WalletService.prototype._endpointIsSynced = function() {
var self = this;
return function(req, res) {
res.status(200).jsonp({ result: !self.node.services.db.syncing });
};
};
WalletService.prototype._endpointJobStatus = function() {
var self = this;
@ -1195,6 +1203,9 @@ WalletService.prototype.setupRoutes = function(app) {
app.get('/jobs',
s._endpointJobs()
);
app.get('/issynced',
s._endpointIsSynced()
);
};
WalletService.prototype.getRoutePrefix = function() {