From 280f815f9795b9ccbaeb6aa7d4bc8d4ff0f6d7f1 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 10 Feb 2014 14:10:49 -0300 Subject: [PATCH] index for output spend matching (speeds ups tx api --- lib/TransactionDb.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 4f1dbe4..06a558b 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -103,8 +103,15 @@ function spec(b) { assert(typeof j !== 'undefined','Spent could not be stored: tx ' + txid + 'spend in TX:' + k[2] + ',' + k[3]+ ' j:' + j); - ret[j].spendTxId = v[0]; - ret[j].spendIndex = parseInt(v[1]); +/// TODO Handle multiple addresses here! + if (ret[j].spendTxId) { + // double spend! + assert(0); + } + else { + ret[j].spendTxId = v[0]; + ret[j].spendIndex = parseInt(v[1]); + } }) .on('error', function (err) { return cb(err);