refactor.

This commit is contained in:
Christopher Jeffrey 2016-03-11 22:58:01 -08:00
parent dc05362ad1
commit 9b90111a0a

View File

@ -1263,8 +1263,6 @@ ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
};
ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
var spent = true;
if (hash.hash)
hash = hash.hash('hex');
@ -1277,29 +1275,19 @@ ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
keyAsBuffer: false
});
(function next() {
iter.next(function(err, key, value) {
if (err) {
return iter.end(function() {
done(err);
});
}
iter.next(function(err, key, value) {
if (err) {
return iter.end(function() {
callback(err);
});
}
if (key === undefined)
return iter.end(done);
spent = false;
iter.end(done);
iter.end(function(err) {
if (err)
return callback(err);
return callback(null, key === undefined);
});
})();
function done(err) {
if (err)
return callback(err);
return callback(null, spent);
}
});
};
ChainDB.prototype.hasTX = function hasTX(hash, callback) {