refactor(minor): part changed to partial_id; and more to data

This commit is contained in:
Damian Mee 2014-09-20 18:54:21 +02:00
parent 5a78376ad5
commit f15f6d9a0a
2 changed files with 14 additions and 14 deletions

View file

@ -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); db.recordBill(deviceFingerprint, rawTrade, cb);
}; };

View file

@ -151,7 +151,7 @@ exports.getPendingAmount = function getPendingAmount(txId, cb) {
// if there are txs, substract already sent amount // if there are txs, substract already sent amount
if (results.txs.rows.length > 0) { 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.satoshis = lastBill.total_satoshis;
newTx.fiat = lastBill.total_fiat; newTx.fiat = lastBill.total_fiat;
@ -192,9 +192,9 @@ exports.summonTx = function summonTx(deviceFingerprint, tx, cb) {
tx.fiat tx.fiat
]; ];
if (tx.part && tx.part > 1) { if (tx.partial_id && tx.partial_id > 1) {
fields.push('part'); fields.push('partial_id');
values.push(tx.part); values.push(tx.partial_id);
} }
// First attampt an INSERT // First attampt an INSERT
@ -213,9 +213,9 @@ exports.summonTx = function summonTx(deviceFingerprint, tx, cb) {
}); });
}; };
// `@more` can contain `part`, `hash`, or `error` // `@data` can contain `partial_id`, `hash`, or `error`
exports.changeTxStatus = function changeTxStatus(txId, newStatus, more, cb) { exports.changeTxStatus = function changeTxStatus(txId, newStatus, data, cb) {
more = more || {}; data = data || {};
cb = typeof cb === 'function' ? cb : function() {}; cb = typeof cb === 'function' ? cb : function() {};
var query = 'UPDATE transactions SET status=$1'; var query = 'UPDATE transactions SET status=$1';
@ -227,21 +227,21 @@ exports.changeTxStatus = function changeTxStatus(txId, newStatus, more, cb) {
if (newStatus === 'error') { if (newStatus === 'error') {
query += ', error=$' + n++; query += ', error=$' + n++;
values.push(more.error); values.push(data.error);
} }
if (newStatus === 'completed') { if (newStatus === 'completed') {
query += ', tx_hash=$' + n++; query += ', tx_hash=$' + n++;
values.push(more.hash); values.push(data.hash);
} }
query += ' WHERE id=$' + n++; query += ' WHERE id=$' + n++;
values.push(txId); values.push(txId);
var part = parseInt(more.part); var partial_id = parseInt(data.partial_id);
if (part > 1) { if (partial_id > 1) {
query += ' AND part=$' + n++; query += ' AND partial_id=$' + n++;
values.push(part); values.push(partial_id);
} }
client.query(query, values, cb); client.query(query, values, cb);