chaindb: fix getFullBlock.

This commit is contained in:
Christopher Jeffrey 2016-12-08 23:53:04 -08:00
parent 5bed0455d2
commit de1f658ede
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -945,7 +945,7 @@ ChainDB.prototype.getRawBlock = co(function* getRawBlock(block) {
ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) {
var block = yield this.getBlock(hash);
var i, j, view, undo, tx, input;
var i, j, view, undo, tx, input, hash, coins;
if (!block)
return;
@ -958,8 +958,22 @@ ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) {
for (i = block.txs.length - 1; i > 0; i--) {
tx = block.txs[i];
for (j = tx.inputs.length - 1; j >= 0; j--) {
input = tx.inputs[j];
hash = input.prevout.hash;
if (!view.has(hash)) {
assert(!undo.isEmpty());
if (undo.top().height === -1) {
coins = new Coins();
coins.hash = hash;
coins.coinbase = false;
view.add(coins);
}
}
input.coin = undo.apply(view, input.prevout);
}
}