chain: post-verify transactions due to potential of rejected promises.

This commit is contained in:
Christopher Jeffrey 2017-07-10 18:16:41 -07:00
parent d7970882b3
commit ff856fd6c2
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -547,7 +547,6 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
let jobs = []; let jobs = [];
let sigops = 0; let sigops = 0;
let reward = 0; let reward = 0;
let valid;
if (this.options.spv) if (this.options.spv)
return view; return view;
@ -615,15 +614,13 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
'bad-cb-amount', 'bad-cb-amount',
100); 100);
} }
// Push onto verification queue.
jobs.push(tx.verifyAsync(view, state.flags, this.workers));
} }
// Add new coins. // Add new coins.
view.addTX(tx, height); view.addTX(tx, height);
} }
// Skip script verification.
if (historical) if (historical)
return view; return view;
@ -637,10 +634,14 @@ Chain.prototype.verifyInputs = async function verifyInputs(block, prev, state) {
100); 100);
} }
// Verify all txs in parallel. // Push onto verification queue.
valid = await co.every(jobs); for (let i = 1; i < block.txs.length; i++) {
let tx = block.txs[i];
jobs.push(tx.verifyAsync(view, state.flags, this.workers));
}
if (!valid) { // Verify all txs in parallel.
if (!(await co.every(jobs))) {
throw new VerifyError(block, throw new VerifyError(block,
'invalid', 'invalid',
'mandatory-script-verify-flag-failed', 'mandatory-script-verify-flag-failed',