refactor.
This commit is contained in:
parent
dc05362ad1
commit
9b90111a0a
@ -1263,8 +1263,6 @@ ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
|
ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
|
||||||
var spent = true;
|
|
||||||
|
|
||||||
if (hash.hash)
|
if (hash.hash)
|
||||||
hash = hash.hash('hex');
|
hash = hash.hash('hex');
|
||||||
|
|
||||||
@ -1277,29 +1275,19 @@ ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
|
|||||||
keyAsBuffer: false
|
keyAsBuffer: false
|
||||||
});
|
});
|
||||||
|
|
||||||
(function next() {
|
iter.next(function(err, key, value) {
|
||||||
iter.next(function(err, key, value) {
|
if (err) {
|
||||||
if (err) {
|
return iter.end(function() {
|
||||||
return iter.end(function() {
|
callback(err);
|
||||||
done(err);
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (key === undefined)
|
iter.end(function(err) {
|
||||||
return iter.end(done);
|
if (err)
|
||||||
|
return callback(err);
|
||||||
spent = false;
|
return callback(null, key === undefined);
|
||||||
|
|
||||||
iter.end(done);
|
|
||||||
});
|
});
|
||||||
})();
|
});
|
||||||
|
|
||||||
function done(err) {
|
|
||||||
if (err)
|
|
||||||
return callback(err);
|
|
||||||
|
|
||||||
return callback(null, spent);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ChainDB.prototype.hasTX = function hasTX(hash, callback) {
|
ChainDB.prototype.hasTX = function hasTX(hash, callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user