From fcc3f52f720756c58fe80d29e9e47965fab122a1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 16 Jan 2017 16:14:08 -0800 Subject: [PATCH] chaindb: cleanup. --- lib/blockchain/chaindb.js | 42 +++++---------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index bcaee47b..8159c5c8 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -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; }); /**