This commit is contained in:
Christopher Jeffrey 2016-03-11 22:47:55 -08:00
parent 8f85f0b5c9
commit 908ddc8254
4 changed files with 15 additions and 25 deletions

View File

@ -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)
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;
segwit = true;
}

View File

@ -853,13 +853,8 @@ ChainDB.prototype.getCoinsByAddress = function getCoinsByAddress(addresses, opti
});
}
if (key === undefined) {
return iter.end(function(err) {
if (err)
return done(err);
done();
});
}
if (key === undefined)
return iter.end(done);
parts = key.split('/');
hash = parts[3];
@ -954,13 +949,8 @@ ChainDB.prototype.getTXByAddress = function getTXByAddress(addresses, options, c
});
}
if (key === undefined) {
return iter.end(function(err) {
if (err)
return done(err);
done();
});
}
if (key === undefined)
return iter.end(done);
hash = key.split('/')[3];
@ -1262,7 +1252,6 @@ ChainDB.prototype._getTX = function _getTX(hash, callback) {
// For BIP30
// https://bitcointalk.org/index.php?topic=67738.0
ChainDB.prototype.isUnspentTX = function isUnspentTX(hash, callback) {
return callback(null, false);
if (this.options.spv)
return callback(null, false);
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) {
var spent = true;
return callback(null, false);
// Important!
if (hash.hash)
hash = hash.hash('hex');
@ -1303,7 +1290,6 @@ ChainDB.prototype.isSpentTX = function isSpentTX(hash, callback) {
spent = false;
// IMPORTANT!
iter.end(done);
});
})();
@ -1396,7 +1382,9 @@ ChainDB.prototype._pruneTX = function _pruneTX(tx, batch, callback) {
// they should be safe to delete anyway at the
// future height. It's unlikely there will be
// _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();
}
@ -1456,8 +1444,8 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
var self = this;
var hashes = [];
var iter = self.db.db.iterator({
gte: 't/q/' + block.height,
lte: 't/q/' + block.height + '~',
gte: 't/q/' + pad32(block.height),
lte: 't/q/' + pad32(block.height) + '~',
keys: true,
values: false,
fillCache: false,
@ -1466,7 +1454,7 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
(function next() {
iter.next(function(err, key, value) {
var parts, hash, index;
var parts, hash;
if (err) {
return iter.end(function() {
@ -1491,7 +1479,7 @@ ChainDB.prototype._pruneQueue = function _pruneQueue(block, batch, callback) {
return callback(err);
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) {
batch.del('t/q/' + block.height + '/' + hash);

View File

@ -44,7 +44,8 @@ Fullnode.prototype._init = function _init() {
this.chain = new bcoin.chain(this, {
preload: false,
fsync: false,
prune: false
prune: false,
useCheckpoints: false
});
// Mempool needs access to blockdb.

View File

@ -1728,6 +1728,7 @@ utils.indexOf = function indexOf(arr, buf) {
};
utils.pad32 = function pad32(num) {
assert(num >= 0);
num = num + '';
while (num.length < 10)
num = '0' + num;