chaindb: fix getCoinView.
This commit is contained in:
parent
4e9bec4cd3
commit
c9fbaae0da
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user