From f15f6d9a0aec179064f25aadbd6e223b982f16d3 Mon Sep 17 00:00:00 2001 From: Damian Mee Date: Sat, 20 Sep 2014 18:54:21 +0200 Subject: [PATCH] refactor(minor): part changed to partial_id; and more to data --- lib/plugins.js | 2 +- lib/postgresql_interface.js | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index 3aa0950e..c3bac95f 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -268,7 +268,7 @@ exports.trade = function trade(rawTrade, deviceFingerprint, cb) { }); } - // record (vel log) inserted bill + // record/log inserted bill db.recordBill(deviceFingerprint, rawTrade, cb); }; diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index 20ba5b5c..d22594cb 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -151,7 +151,7 @@ exports.getPendingAmount = function getPendingAmount(txId, cb) { // if there are txs, substract already sent amount if (results.txs.rows.length > 0) { - newTx.part = results.txs.rows.length + 1; + newTx.partial_id = results.txs.rows.length + 1; newTx.satoshis = lastBill.total_satoshis; newTx.fiat = lastBill.total_fiat; @@ -192,9 +192,9 @@ exports.summonTx = function summonTx(deviceFingerprint, tx, cb) { tx.fiat ]; - if (tx.part && tx.part > 1) { - fields.push('part'); - values.push(tx.part); + if (tx.partial_id && tx.partial_id > 1) { + fields.push('partial_id'); + values.push(tx.partial_id); } // First attampt an INSERT @@ -213,9 +213,9 @@ exports.summonTx = function summonTx(deviceFingerprint, tx, cb) { }); }; -// `@more` can contain `part`, `hash`, or `error` -exports.changeTxStatus = function changeTxStatus(txId, newStatus, more, cb) { - more = more || {}; +// `@data` can contain `partial_id`, `hash`, or `error` +exports.changeTxStatus = function changeTxStatus(txId, newStatus, data, cb) { + data = data || {}; cb = typeof cb === 'function' ? cb : function() {}; var query = 'UPDATE transactions SET status=$1'; @@ -227,21 +227,21 @@ exports.changeTxStatus = function changeTxStatus(txId, newStatus, more, cb) { if (newStatus === 'error') { query += ', error=$' + n++; - values.push(more.error); + values.push(data.error); } if (newStatus === 'completed') { query += ', tx_hash=$' + n++; - values.push(more.hash); + values.push(data.hash); } query += ' WHERE id=$' + n++; values.push(txId); - var part = parseInt(more.part); - if (part > 1) { - query += ' AND part=$' + n++; - values.push(part); + var partial_id = parseInt(data.partial_id); + if (partial_id > 1) { + query += ' AND partial_id=$' + n++; + values.push(partial_id); } client.query(query, values, cb);