rpc: minor refactor for gbt deps.

This commit is contained in:
Christopher Jeffrey 2017-03-17 04:32:41 -07:00
parent f778a8c1b5
commit e821eb10bf
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1203,7 +1203,7 @@ RPC.prototype._createTemplate = co(function* _createTemplate(maxVersion, coinbas
// Build an index of every transaction.
for (i = 0; i < attempt.items.length; i++) {
entry = attempt.items[i];
index[entry.hash] = i;
index[entry.hash] = i + 1;
}
// Calculate dependencies for each transaction.
@ -1215,9 +1215,13 @@ RPC.prototype._createTemplate = co(function* _createTemplate(maxVersion, coinbas
for (j = 0; j < tx.inputs.length; j++) {
input = tx.inputs[j];
dep = index[input.prevout.hash];
if (dep != null && deps.indexOf(dep + 1) === -1) {
assert(dep < i);
deps.push(dep + 1);
if (dep == null)
continue;
if (deps.indexOf(dep) === -1) {
assert(dep < i + 1);
deps.push(dep);
}
}