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

View File

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