chain: remove isCoinbase calls.

This commit is contained in:
Christopher Jeffrey 2017-07-09 13:06:03 -07:00
parent 73e61e864a
commit e65f6e26c3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 11 additions and 8 deletions

View File

@ -553,9 +553,11 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
return view;
// Check all transactions
for (let tx of block.txs) {
for (let i = 0; i < block.txs.length; i++) {
let tx = block.txs[i];
// Ensure tx is not double spending an output.
if (!tx.isCoinbase()) {
if (i > 0) {
if (!(await view.spendInputs(this.db, tx))) {
assert(!historical, 'BUG: Spent inputs in historical data!');
throw new VerifyError(block,
@ -573,7 +575,7 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
}
// Verify sequence locks.
if (!tx.isCoinbase() && tx.version >= 2) {
if (i > 0 && tx.version >= 2) {
let valid = await this.verifyLocks(prev, tx, view, state.lockFlags);
if (!valid) {
@ -595,7 +597,7 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
}
// Contextual sanity checks.
if (!tx.isCoinbase()) {
if (i > 0) {
let [fee, reason, score] = tx.checkInputs(view, height);
if (fee === -1) {

View File

@ -1230,7 +1230,8 @@ ChainDB.prototype.scan = async function scan(start, filter, iter) {
'Scanning block %s (%d).',
entry.rhash(), entry.height);
for (let tx of block.txs) {
for (let i = 0; i < block.txs.length; i++) {
let tx = block.txs[i];
let found = false;
for (let i = 0; i < tx.outputs.length; i++) {
@ -1252,7 +1253,7 @@ ChainDB.prototype.scan = async function scan(start, filter, iter) {
continue;
}
if (tx.isCoinbase())
if (i === 0)
continue;
for (let {prevout} of tx.inputs) {
@ -1701,7 +1702,7 @@ ChainDB.prototype.connectBlock = async function connectBlock(entry, block, view)
for (let i = 0; i < block.txs.length; i++) {
let tx = block.txs[i];
if (!tx.isCoinbase()) {
if (i > 0) {
for (let input of tx.inputs)
this.pending.spend(view.getOutput(input));
}
@ -1752,7 +1753,7 @@ ChainDB.prototype.disconnectBlock = async function disconnectBlock(entry, block)
for (let i = block.txs.length - 1; i >= 0; i--) {
let tx = block.txs[i];
if (!tx.isCoinbase()) {
if (i > 0) {
await view.ensureInputs(this, tx);
for (let j = tx.inputs.length - 1; j >= 0; j--) {