From e821eb10bf27a7512f6af4f36e5ae292be1df1f9 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 17 Mar 2017 04:32:41 -0700 Subject: [PATCH] rpc: minor refactor for gbt deps. --- lib/http/rpc.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/http/rpc.js b/lib/http/rpc.js index cac8ee1d..fea89f63 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -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); } }