chaindb: cleanup.

This commit is contained in:
Christopher Jeffrey 2017-01-16 16:14:08 -08:00
parent ac7f194c4d
commit fcc3f52f72
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -336,36 +336,6 @@ ChainDB.prototype.getHash = co(function* getHash(height) {
return hash.toString('hex');
});
/**
* Get both hash and height depending on the value passed in.
* @param {Hash|Number} block - Can be a hash or height.
* @returns {Promise}
*/
ChainDB.prototype.getBoth = co(function* getBoth(block) {
var hash, height;
if (typeof block === 'number') {
height = block;
hash = yield this.getHash(height);
if (hash == null)
height = -1;
return new BlockPair(hash, height);
}
assert(typeof block === 'string');
hash = block;
height = yield this.getHeight(hash);
if (height === -1)
hash = null;
return new BlockPair(hash, height);
});
/**
* Retrieve a chain entry by height.
* @param {Number} height
@ -454,16 +424,14 @@ ChainDB.prototype.getEntry = function getEntry(block) {
};
/**
* Test whether the chain contains a block in the
* main chain or an alternate chain. Alternate chains will only
* be tested if the lookup is done by hash.
* @param {Hash|Number} block - Hash or height.
* Test whether the chain contains a block.
* @param {Hash} hash
* @returns {Promise} - Returns Boolean.
*/
ChainDB.prototype.hasEntry = co(function* hasEntry(block) {
var item = yield this.getBoth(block);
return item.hash != null;
ChainDB.prototype.hasEntry = co(function* hasEntry(hash) {
var height = yield this.getHeight(hash);
return height !== -1;
});
/**