datastore fixes.
This commit is contained in:
parent
b88fc5b0ed
commit
18145ad541
@ -849,8 +849,8 @@ ChainDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti
|
|||||||
|
|
||||||
utils.forEach(addresses, function(address, done) {
|
utils.forEach(addresses, function(address, done) {
|
||||||
var iter = self.db.db.iterator({
|
var iter = self.db.db.iterator({
|
||||||
gte: 'u/a/' + address,
|
gte: 'u/a/' + address + '/',
|
||||||
lte: 'u/a/' + address + '~',
|
lte: 'u/a/' + address + '/~',
|
||||||
keys: true,
|
keys: true,
|
||||||
values: true,
|
values: true,
|
||||||
fillCache: true,
|
fillCache: true,
|
||||||
@ -945,8 +945,8 @@ ChainDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c
|
|||||||
|
|
||||||
utils.forEach(addresses, function(address, done) {
|
utils.forEach(addresses, function(address, done) {
|
||||||
var iter = self.db.db.iterator({
|
var iter = self.db.db.iterator({
|
||||||
gte: 't/a/' + address,
|
gte: 't/a/' + address + '/',
|
||||||
lte: 't/a/' + address + '~',
|
lte: 't/a/' + address + '/~',
|
||||||
keys: true,
|
keys: true,
|
||||||
values: true,
|
values: true,
|
||||||
fillCache: true,
|
fillCache: true,
|
||||||
@ -977,6 +977,8 @@ ChainDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
hashes.push(hash);
|
hashes.push(hash);
|
||||||
|
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
|
|||||||
@ -330,8 +330,11 @@ DataStore.prototype.iterator = function iterator(options) {
|
|||||||
function Iterator(store, options) {
|
function Iterator(store, options) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this._db = store._db;
|
this._db = store._db;
|
||||||
if (options && options.keys === false)
|
if (!options)
|
||||||
|
options = {};
|
||||||
|
if (options.keys === false)
|
||||||
options.keys = true;
|
options.keys = true;
|
||||||
|
this.options = options;
|
||||||
this.iterator = this._db.db.iterator(options);
|
this.iterator = this._db.db.iterator(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,18 +346,19 @@ Iterator.prototype.seek = function seek(key) {
|
|||||||
// hashes directly in the db (unless they're
|
// hashes directly in the db (unless they're
|
||||||
// the same length as offset).
|
// the same length as offset).
|
||||||
function isDirect(key) {
|
function isDirect(key) {
|
||||||
return !/^(b\/b\/|t\/t\/)/.test(key);
|
return !/^(b\/b\/|t\/t\/|c\/c\/|u\/t\/)/.test(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator.prototype.next = function next(callback) {
|
Iterator.prototype.next = function next(callback) {
|
||||||
|
var self = this;
|
||||||
return this.iterator.next(function(err, key, value) {
|
return this.iterator.next(function(err, key, value) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
if (value) {
|
if (self.options.values !== false && value) {
|
||||||
if (isDirect(key))
|
if (isDirect(key))
|
||||||
return callback(null, key, value);
|
return callback(null, key, value);
|
||||||
return self.getData(value, function(err, data) {
|
return self.store.getData(value, function(err, data) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err);
|
return callback(err);
|
||||||
return callback(null, key, data);
|
return callback(null, key, data);
|
||||||
@ -634,9 +638,8 @@ DataStore.prototype.write = function write(fd, offset, data, callback) {
|
|||||||
|
|
||||||
(function next() {
|
(function next() {
|
||||||
fs.write(fd, data, index, size, offset, function(err, bytes) {
|
fs.write(fd, data, index, size, offset, function(err, bytes) {
|
||||||
if (err) {
|
if (err)
|
||||||
return callback(err, index);
|
return callback(err);
|
||||||
}
|
|
||||||
|
|
||||||
if (!bytes)
|
if (!bytes)
|
||||||
return callback(self._ioError('write', size, offset));
|
return callback(self._ioError('write', size, offset));
|
||||||
|
|||||||
@ -1728,7 +1728,7 @@ utils.indexOf = function indexOf(arr, buf) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
utils.pad32 = function pad32(num) {
|
utils.pad32 = function pad32(num) {
|
||||||
assert(num >= 0);
|
assert(num >= 0, num);
|
||||||
num = num + '';
|
num = num + '';
|
||||||
while (num.length < 10)
|
while (num.length < 10)
|
||||||
num = '0' + num;
|
num = '0' + num;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user