bill-reporting WIP
This commit is contained in:
parent
3befd4cd94
commit
8c50444e80
2 changed files with 24 additions and 1 deletions
|
|
@ -20,6 +20,25 @@ var PostgresqlInterface = function (conString) {
|
|||
PostgresqlInterface.factory = function factory(conString) { return new PostgresqlInterface(conString); };
|
||||
module.exports = PostgresqlInterface;
|
||||
|
||||
PostgresqlInterface.prototype.recordBill =
|
||||
function recordBill(deviceFingerprint, rec, cb) {
|
||||
|
||||
this.client.query('INSERT INTO bills (device_fingerprint, denomination, currency_code, ' +
|
||||
'transaction_id) ' +
|
||||
'VALUES ($1, $2, $3, $4)',
|
||||
[deviceFingerprint, rec.fiat, rec.currency, rec.txId],
|
||||
cb);
|
||||
};
|
||||
|
||||
PostgresqlInterface.prototype.recordBillValidatorEvent =
|
||||
function recordBillValidatorEvent(deviceFingerprint, event, cb) {
|
||||
|
||||
this.client.query('INSERT INTO bill_validator_events (device_fingerprint, event_type, note)' +
|
||||
'VALUES ($1, $2, $3)',
|
||||
[deviceFingerprint, event.eventType, event.note],
|
||||
cb);
|
||||
};
|
||||
|
||||
PostgresqlInterface.prototype.summonTransaction =
|
||||
function summonTransaction(deviceFingerprint, tx, cb) {
|
||||
// First do an INSERT
|
||||
|
|
|
|||
|
|
@ -196,6 +196,10 @@ Trader.prototype.sendBitcoins = function (deviceFingerprint, tx, cb) {
|
|||
};
|
||||
|
||||
Trader.prototype.trade = function (rec, deviceFingerprint) {
|
||||
self.db.recordBill(deviceFingerprint, rec, function (err) {
|
||||
if (err) logger.error(err);
|
||||
});
|
||||
|
||||
// This is where we record starting trade balance at the beginning
|
||||
// of the user session
|
||||
var sessionInfo = this._sessionInfo[deviceFingerprint];
|
||||
|
|
@ -336,7 +340,7 @@ Trader.prototype.pollRate = function (callback) {
|
|||
|
||||
logger.debug('got rates: %j', resRates);
|
||||
self.rateInfo = {rates: resRates, timestamp: new Date()};
|
||||
callback && callback();
|
||||
if (callback) callback();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue