wip new routes.
This commit is contained in:
parent
42c957d02a
commit
0788da0e45
@ -1171,8 +1171,8 @@ AddressService.prototype.getAddressTxidsWithHeights = function(address, options,
|
|||||||
var opts = options || {};
|
var opts = options || {};
|
||||||
var txids = {};
|
var txids = {};
|
||||||
|
|
||||||
var start = self._encoding.encodeAddressIndexKey(address, opts.start || 0, '00');
|
var start = self._encoding.encodeAddressIndexKey(address, opts.start || 0); //the start and end must be the same length
|
||||||
var end = self._encoding.encodeAddressIndexKey(address, opts.end || 0xffffffff);
|
var end = Buffer.concat([ start.slice(0, -36), new Buffer((opts.end || 0xffffffff), 'hex') ]);
|
||||||
|
|
||||||
var stream = self.store.createKeyStream({
|
var stream = self.store.createKeyStream({
|
||||||
gte: start,
|
gte: start,
|
||||||
|
|||||||
@ -62,6 +62,7 @@ function DB(options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._sync = new Sync(this.node, this);
|
this._sync = new Sync(this.node, this);
|
||||||
|
this.syncing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(DB, Service);
|
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.store = levelup(self.dataPath, { db: self.levelupStore, keyEncoding: 'binary', valueEncoding: 'binary'});
|
||||||
|
|
||||||
self._sync.on('error', function(err) {
|
self._sync.on('error', function(err) {
|
||||||
|
self.syncing = false;
|
||||||
log.error(err);
|
log.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -160,6 +162,7 @@ DB.prototype.start = function(callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self._sync.on('synced', function() {
|
self._sync.on('synced', function() {
|
||||||
|
self.syncing = false;
|
||||||
log.info('Initial sync complete');
|
log.info('Initial sync complete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -566,12 +566,10 @@ WalletService.prototype._endpointPostAddresses = function() {
|
|||||||
if (!addresses || !addresses.length) {
|
if (!addresses || !addresses.length) {
|
||||||
return utils.sendError(new Error('addresses are required when creating a wallet.'), res);
|
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) {
|
if (!walletId) {
|
||||||
return utils.sendError(new Error('WalletId must be given.'), res);
|
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()) {
|
if (!self._isJobQueueReady()) {
|
||||||
return utils.sendError(new Error('Job queue is currently overloaded, please try again later.'), res);
|
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() {
|
WalletService.prototype._endpointJobStatus = function() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -1195,6 +1203,9 @@ WalletService.prototype.setupRoutes = function(app) {
|
|||||||
app.get('/jobs',
|
app.get('/jobs',
|
||||||
s._endpointJobs()
|
s._endpointJobs()
|
||||||
);
|
);
|
||||||
|
app.get('/issynced',
|
||||||
|
s._endpointIsSynced()
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletService.prototype.getRoutePrefix = function() {
|
WalletService.prototype.getRoutePrefix = function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user