This commit is contained in:
Patrick Nagurny 2015-09-15 17:25:41 -04:00
parent 00d3a0ba67
commit e6b850124c
1 changed files with 8 additions and 2 deletions

View File

@ -199,13 +199,19 @@ DB.prototype.getBlock = function(hash, callback) {
});
};
/**
* get block hashes between two timestamps
* @param {Number} start - first timestamp, in seconds, inclusive
* @param {Number} end - second timestamp, in seconds, inclusive
* @param {Function} callback
*/
DB.prototype.getBlockHashesByTimestamp = function(start, end, callback) {
var self = this;
var hashes = [];
var stream = this.store.createReadStream({
start: this._encodeBlockIndexKey(start),
end: this._encodeBlockIndexKey(end),
gte: this._encodeBlockIndexKey(start),
lte: this._encodeBlockIndexKey(end),
valueEncoding: 'binary',
keyEncoding: 'binary'
});