chaindb: fix getCoinView.

This commit is contained in:
Christopher Jeffrey 2016-12-07 18:03:32 -08:00
parent 4e9bec4cd3
commit c9fbaae0da
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 6 additions and 14 deletions

View File

@ -857,15 +857,15 @@ ChainDB.prototype.hasCoins = function hasCoins(hash) {
ChainDB.prototype.getCoinView = co(function* getCoinView(tx, callback) {
var view = new CoinView();
var prevout = tx.getPrevout();
var i, prev, coins;
var i, hash, coins;
for (i = 0; i < prevout.length; i++) {
prev = prevout[i];
coins = yield this.getCoins(prev);
hash = prevout[i];
coins = yield this.getCoins(hash);
if (!coins) {
coins = new Coins();
coins.hash = prev.hash;
coins.hash = hash;
view.add(coins);
continue;
}

View File

@ -1309,19 +1309,11 @@ Mempool.prototype.injectCoins = function injectCoins(tx, view) {
for (i = 0; i < tx.inputs.length; i++) {
input = tx.inputs[i];
prevout = input.prevout;
if (!view.has(prevout.hash)) {
missing.push(prevout.hash);
continue;
}
coin = view.getCoin(prevout.hash, prevout.index);
if (!coin) {
throw new VerifyError(tx,
'duplicate',
'bad-txns-inputs-spent',
0);
missing.push(prevout.hash);
continue;
}
input.coin = coin;