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