txdb: refactor range queries.
This commit is contained in:
parent
8a158bbe41
commit
4e5ec39cc9
@ -1310,21 +1310,21 @@ TXDB.prototype.getLocked = function getLocked() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TXDB.prototype.getHistoryHashes = function getHistoryHashes(account) {
|
TXDB.prototype.getHistoryHashes = function getHistoryHashes(account) {
|
||||||
return this.keys({
|
if (acount != null) {
|
||||||
gte: account != null
|
return this.keys({
|
||||||
? layout.T(account, constants.NULL_HASH)
|
gte: layout.T(account, constants.NULL_HASH),
|
||||||
: layout.t(constants.NULL_HASH),
|
lte: layout.T(account, constants.HIGH_HASH),
|
||||||
lte: account != null
|
parse: function(key) {
|
||||||
? layout.T(account, constants.HIGH_HASH)
|
|
||||||
: layout.t(constants.HIGH_HASH),
|
|
||||||
parse: function(key) {
|
|
||||||
if (account != null) {
|
|
||||||
key = layout.Tt(key);
|
key = layout.Tt(key);
|
||||||
return key[1];
|
return key[1];
|
||||||
}
|
}
|
||||||
key = layout.tt(key);
|
});
|
||||||
return key;
|
}
|
||||||
}
|
|
||||||
|
return this.keys({
|
||||||
|
gte: layout.t(constants.NULL_HASH),
|
||||||
|
lte: layout.t(constants.HIGH_HASH),
|
||||||
|
parse: layout.tt
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1335,21 +1335,21 @@ TXDB.prototype.getHistoryHashes = function getHistoryHashes(account) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TXDB.prototype.getUnconfirmedHashes = function getUnconfirmedHashes(account) {
|
TXDB.prototype.getUnconfirmedHashes = function getUnconfirmedHashes(account) {
|
||||||
return this.keys({
|
if (acount != null) {
|
||||||
gte: account != null
|
return this.keys({
|
||||||
? layout.P(account, constants.NULL_HASH)
|
gte: layout.P(account, constants.NULL_HASH),
|
||||||
: layout.p(constants.NULL_HASH),
|
lte: layout.P(account, constants.HIGH_HASH),
|
||||||
lte: account != null
|
parse: function(key) {
|
||||||
? layout.P(account, constants.HIGH_HASH)
|
|
||||||
: layout.p(constants.HIGH_HASH),
|
|
||||||
parse: function(key) {
|
|
||||||
if (account != null) {
|
|
||||||
key = layout.Pp(key);
|
key = layout.Pp(key);
|
||||||
return key[1];
|
return key[1];
|
||||||
}
|
}
|
||||||
key = layout.pp(key);
|
});
|
||||||
return key;
|
}
|
||||||
}
|
|
||||||
|
return this.keys({
|
||||||
|
gte: layout.p(constants.NULL_HASH),
|
||||||
|
lte: layout.p(constants.HIGH_HASH),
|
||||||
|
parse: layout.pp
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1360,18 +1360,21 @@ TXDB.prototype.getUnconfirmedHashes = function getUnconfirmedHashes(account) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TXDB.prototype.getOutpoints = function getOutpoints(account) {
|
TXDB.prototype.getOutpoints = function getOutpoints(account) {
|
||||||
return this.keys({
|
if (account != null) {
|
||||||
gte: account != null
|
return this.keys({
|
||||||
? layout.C(account, constants.NULL_HASH, 0)
|
gte: layout.C(account, constants.NULL_HASH, 0),
|
||||||
: layout.c(constants.NULL_HASH, 0),
|
lte: layout.C(account, constants.HIGH_HASH, 0xffffffff),
|
||||||
lte: account != null
|
parse: function(key) {
|
||||||
? layout.C(account, constants.HIGH_HASH, 0xffffffff)
|
|
||||||
: layout.c(constants.HIGH_HASH, 0xffffffff),
|
|
||||||
parse: function(key) {
|
|
||||||
if (account != null) {
|
|
||||||
key = layout.Cc(key);
|
key = layout.Cc(key);
|
||||||
return new Outpoint(key[1], key[2]);
|
return new Outpoint(key[1], key[2]);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.keys({
|
||||||
|
gte: layout.c(constants.NULL_HASH, 0),
|
||||||
|
lte: layout.c(constants.HIGH_HASH, 0xffffffff),
|
||||||
|
parse: function(key) {
|
||||||
key = layout.cc(key);
|
key = layout.cc(key);
|
||||||
return new Outpoint(key[0], key[1]);
|
return new Outpoint(key[0], key[1]);
|
||||||
}
|
}
|
||||||
@ -1400,20 +1403,25 @@ TXDB.prototype.getHeightRangeHashes = function getHeightRangeHashes(account, opt
|
|||||||
start = options.start || 0;
|
start = options.start || 0;
|
||||||
end = options.end || 0xffffffff;
|
end = options.end || 0xffffffff;
|
||||||
|
|
||||||
return this.keys({
|
if (account != null) {
|
||||||
gte: account != null
|
return this.keys({
|
||||||
? layout.H(account, start, constants.NULL_HASH)
|
gte: layout.H(account, start, constants.NULL_HASH),
|
||||||
: layout.h(start, constants.NULL_HASH),
|
lte: layout.H(account, end, constants.HIGH_HASH),
|
||||||
lte: account != null
|
limit: options.limit,
|
||||||
? layout.H(account, end, constants.HIGH_HASH)
|
reverse: options.reverse,
|
||||||
: layout.h(end, constants.HIGH_HASH),
|
parse: function(key) {
|
||||||
limit: options.limit,
|
|
||||||
reverse: options.reverse,
|
|
||||||
parse: function(key) {
|
|
||||||
if (account != null) {
|
|
||||||
key = layout.Hh(key);
|
key = layout.Hh(key);
|
||||||
return key[2];
|
return key[2];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.keys({
|
||||||
|
gte: layout.h(start, constants.NULL_HASH),
|
||||||
|
lte: layout.h(end, constants.HIGH_HASH),
|
||||||
|
limit: options.limit,
|
||||||
|
reverse: options.reverse,
|
||||||
|
parse: function(key) {
|
||||||
key = layout.hh(key);
|
key = layout.hh(key);
|
||||||
return key[1];
|
return key[1];
|
||||||
}
|
}
|
||||||
@ -1452,20 +1460,25 @@ TXDB.prototype.getRangeHashes = function getRangeHashes(account, options) {
|
|||||||
start = options.start || 0;
|
start = options.start || 0;
|
||||||
end = options.end || 0xffffffff;
|
end = options.end || 0xffffffff;
|
||||||
|
|
||||||
return this.keys({
|
if (account != null) {
|
||||||
gte: account != null
|
return this.keys({
|
||||||
? layout.M(account, start, constants.NULL_HASH)
|
gte: layout.M(account, start, constants.NULL_HASH),
|
||||||
: layout.m(start, constants.NULL_HASH),
|
lte: layout.M(account, end, constants.HIGH_HASH),
|
||||||
lte: account != null
|
limit: options.limit,
|
||||||
? layout.M(account, end, constants.HIGH_HASH)
|
reverse: options.reverse,
|
||||||
: layout.m(end, constants.HIGH_HASH),
|
parse: function(key) {
|
||||||
limit: options.limit,
|
|
||||||
reverse: options.reverse,
|
|
||||||
parse: function(key) {
|
|
||||||
if (account != null) {
|
|
||||||
key = layout.Mm(key);
|
key = layout.Mm(key);
|
||||||
return key[2];
|
return key[2];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.keys({
|
||||||
|
gte: layout.m(start, constants.NULL_HASH),
|
||||||
|
lte: layout.m(end, constants.HIGH_HASH),
|
||||||
|
limit: options.limit,
|
||||||
|
reverse: options.reverse,
|
||||||
|
parse: function(key) {
|
||||||
key = layout.mm(key);
|
key = layout.mm(key);
|
||||||
return key[1];
|
return key[1];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user