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);
};

View file

@ -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);