Minor cleanup of utxoset input checking
This commit is contained in:
parent
d880bd1ccc
commit
1515f68748
|
@ -253,28 +253,23 @@ impl UtxoSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut skipped_genesis = false;
|
for tx in block.txdata.iter().skip(1) {
|
||||||
for tx in block.txdata.iter() {
|
|
||||||
let txid = tx.bitcoin_hash();
|
let txid = tx.bitcoin_hash();
|
||||||
// Put the removed utxos into the stxo cache, in case we need to rewind
|
// Put the removed utxos into the stxo cache, in case we need to rewind
|
||||||
if skipped_genesis {
|
self.spent_txos.get_mut(spent_idx).reserve_additional(tx.input.len());
|
||||||
self.spent_txos.get_mut(spent_idx).reserve_additional(tx.input.len());
|
for (n, input) in tx.input.iter().enumerate() {
|
||||||
for (n, input) in tx.input.iter().enumerate() {
|
let taken = self.take_utxo(input.prev_hash, input.prev_index);
|
||||||
let taken = self.take_utxo(input.prev_hash, input.prev_index);
|
match taken {
|
||||||
match taken {
|
Some(txo) => { self.spent_txos.get_mut(spent_idx).push(((txid, n as u32), txo)); }
|
||||||
Some(txo) => { self.spent_txos.get_mut(spent_idx).push(((txid, n as u32), txo)); }
|
None => {
|
||||||
None => {
|
if validation >= TxoValidation {
|
||||||
if validation >= TxoValidation {
|
self.rewind(block);
|
||||||
self.rewind(block);
|
return Err(InvalidTx(txid,
|
||||||
return Err(InvalidTx(txid,
|
InputNotFound(input.prev_hash, input.prev_index)));
|
||||||
InputNotFound(input.prev_hash, input.prev_index)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skipped_genesis = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// If we made it here, success!
|
// If we made it here, success!
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue