optimize more.
This commit is contained in:
parent
3e7f1cea42
commit
f95f3e929b
@ -781,7 +781,7 @@ Chain.prototype._findDuplicates = function _findDuplicates(block, prev, callback
|
||||
var hash = tx.hash('hex');
|
||||
|
||||
// BIP30 - Ensure there are no duplicate txids
|
||||
self.db.isUnspentTX(hash, function(err, result) {
|
||||
self.db.hasCoins(hash, function(err, result) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
|
||||
@ -1479,40 +1479,14 @@ ChainDB.prototype.getBlock = function getBlock(hash, callback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether a transaction is unspent (i.e. not yet _fully_ spent).
|
||||
* Check whether coins are still unspent. Necessary for bip30.
|
||||
* @see https://bitcointalk.org/index.php?topic=67738.0
|
||||
* @param {Hash} hash
|
||||
* @param {Function} callback - Returns [Error, Boolean].
|
||||
*/
|
||||
|
||||
ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
|
||||
if (this.options.spv)
|
||||
return callback(null, false);
|
||||
|
||||
return this.isSpentTX(hash, function(err, spent) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
return callback(null, !spent);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether a transaction is _fully_ spent.
|
||||
* @see https://bitcointalk.org/index.php?topic=67738.0
|
||||
* @param {Hash} hash
|
||||
* @param {Function} callback - Returns [Error, Boolean].
|
||||
*/
|
||||
|
||||
ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
|
||||
if (hash.hash)
|
||||
hash = hash.hash('hex');
|
||||
|
||||
this.getCoins(hash, function(err, coins) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
return callback(null, !coins);
|
||||
});
|
||||
ChainDB.prototype.hasCoins = function hasCoins(hash, callback) {
|
||||
this.db.has(layout.c(hash), callback);
|
||||
};
|
||||
|
||||
ChainDB.prototype._pruneBlock = function _pruneBlock(block, batch, callback) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user