cleanup.
This commit is contained in:
parent
8f85f0b5c9
commit
908ddc8254
@ -508,7 +508,7 @@ Chain.prototype._verify = function _verify(block, prev, callback) {
|
|||||||
|
|
||||||
// Segregrated witness is now usable (the-bip-that-really-needs-to-be-rewritten)
|
// Segregrated witness is now usable (the-bip-that-really-needs-to-be-rewritten)
|
||||||
if (network.segwitHeight !== -1 && height >= network.segwitHeight) {
|
if (network.segwitHeight !== -1 && height >= network.segwitHeight) {
|
||||||
if (block.version >= 5 && prev.isUpgraded(5) ) {
|
if (block.version >= 5 && prev.isUpgraded(5)) {
|
||||||
flags |= constants.flags.VERIFY_WITNESS;
|
flags |= constants.flags.VERIFY_WITNESS;
|
||||||
segwit = true;
|
segwit = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -853,13 +853,8 @@ ChainDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === undefined) {
|
if (key === undefined)
|
||||||
return iter.end(function(err) {
|
return iter.end(done);
|
||||||
if (err)
|
|
||||||
return done(err);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
parts = key.split('/');
|
parts = key.split('/');
|
||||||
hash = parts[3];
|
hash = parts[3];
|
||||||
@ -954,13 +949,8 @@ ChainDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === undefined) {
|
if (key === undefined)
|
||||||
return iter.end(function(err) {
|
return iter.end(done);
|
||||||
if (err)
|
|
||||||
return done(err);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
hash = key.split('/')[3];
|
hash = key.split('/')[3];
|
||||||
|
|
||||||
@ -1262,7 +1252,6 @@ ChainDB.prototype._getTX = function _getTX(hash, callback) {
|
|||||||
// For BIP30
|
// For BIP30
|
||||||
// https://bitcointalk.org/index.php?topic=67738.0
|
// https://bitcointalk.org/index.php?topic=67738.0
|
||||||
ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
|
ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
|
||||||
return callback(null, false);
|
|
||||||
if (this.options.spv)
|
if (this.options.spv)
|
||||||
return callback(null, false);
|
return callback(null, false);
|
||||||
return this.isSpentTX(hash, function(err, spent) {
|
return this.isSpentTX(hash, function(err, spent) {
|
||||||
@ -1276,8 +1265,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;
|
var spent = true;
|
||||||
|
|
||||||
return callback(null, false);
|
|
||||||
// Important!
|
|
||||||
if (hash.hash)
|
if (hash.hash)
|
||||||
hash = hash.hash('hex');
|
hash = hash.hash('hex');
|
||||||
|
|
||||||
@ -1303,7 +1290,6 @@ ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
|
|||||||
|
|
||||||
spent = false;
|
spent = false;
|
||||||
|
|
||||||
// IMPORTANT!
|
|
||||||
iter.end(done);
|
iter.end(done);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
@ -1396,7 +1382,9 @@ ChainDB.prototype._pruneTX = function _pruneTX(tx, batch, callback) {
|
|||||||
// they should be safe to delete anyway at the
|
// they should be safe to delete anyway at the
|
||||||
// future height. It's unlikely there will be
|
// future height. It's unlikely there will be
|
||||||
// _another_ reorg to take over 288 blocks.
|
// _another_ reorg to take over 288 blocks.
|
||||||
batch.put('t/q/' + futureHeight + '/' + input.prevout.hash, DUMMY);
|
batch.put(
|
||||||
|
't/q/' + pad32(futureHeight) + '/' + input.prevout.hash,
|
||||||
|
DUMMY);
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1456,8 +1444,8 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var hashes = [];
|
var hashes = [];
|
||||||
var iter = self.db.db.iterator({
|
var iter = self.db.db.iterator({
|
||||||
gte: 't/q/' + block.height,
|
gte: 't/q/' + pad32(block.height),
|
||||||
lte: 't/q/' + block.height + '~',
|
lte: 't/q/' + pad32(block.height) + '~',
|
||||||
keys: true,
|
keys: true,
|
||||||
values: false,
|
values: false,
|
||||||
fillCache: false,
|
fillCache: false,
|
||||||
@ -1466,7 +1454,7 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
|
|||||||
|
|
||||||
(function next() {
|
(function next() {
|
||||||
iter.next(function(err, key, value) {
|
iter.next(function(err, key, value) {
|
||||||
var parts, hash, index;
|
var parts, hash;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return iter.end(function() {
|
return iter.end(function() {
|
||||||
@ -1491,7 +1479,7 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
if (hashes.length)
|
if (hashes.length)
|
||||||
utils.debug('Retroactively pruning txs at height %d', block.height);
|
utils.debug('Retroactively pruning txs at height %d.', block.height);
|
||||||
|
|
||||||
utils.forEachSerial(hashes, function(hash, next) {
|
utils.forEachSerial(hashes, function(hash, next) {
|
||||||
batch.del('t/q/' + block.height + '/' + hash);
|
batch.del('t/q/' + block.height + '/' + hash);
|
||||||
|
|||||||
@ -44,7 +44,8 @@ Fullnode.prototype._init = function _init() {
|
|||||||
this.chain = new bcoin.chain(this, {
|
this.chain = new bcoin.chain(this, {
|
||||||
preload: false,
|
preload: false,
|
||||||
fsync: false,
|
fsync: false,
|
||||||
prune: false
|
prune: false,
|
||||||
|
useCheckpoints: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mempool needs access to blockdb.
|
// Mempool needs access to blockdb.
|
||||||
|
|||||||
@ -1728,6 +1728,7 @@ utils.indexOf = function indexOf(arr, buf) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
utils.pad32 = function pad32(num) {
|
utils.pad32 = function pad32(num) {
|
||||||
|
assert(num >= 0);
|
||||||
num = num + '';
|
num = num + '';
|
||||||
while (num.length < 10)
|
while (num.length < 10)
|
||||||
num = '0' + num;
|
num = '0' + num;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user