WIP
This commit is contained in:
parent
408e4b59d5
commit
c38372a173
3 changed files with 19 additions and 29 deletions
|
|
@ -1,10 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var logger = require('./logger');
|
||||
|
||||
|
||||
var SATOSHI_FACTOR = 1e8;
|
||||
var POLLING_RATE = 60 * 1000; // poll each minute
|
||||
var REAP_RATE = 5 * 1000;
|
||||
|
|
@ -15,7 +13,6 @@ var MIN_CONFIDENCE = 0.7;
|
|||
|
||||
var db = null;
|
||||
|
||||
|
||||
var tickerPlugin = null;
|
||||
var traderPlugin = null;
|
||||
var walletPlugin = null;
|
||||
|
|
@ -242,14 +239,10 @@ function reapTxs() {
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: Run these in parallel and return success
|
||||
exports.trade = function trade(deviceFingerprint, rawTrade, cb) {
|
||||
var tx = {
|
||||
txId: rawTrade.txId,
|
||||
toAddress: rawTrade.toAddress,
|
||||
currencyCode: rawTrade.currency
|
||||
};
|
||||
db.addPendingTx(deviceFingerprint, tx);
|
||||
|
||||
// TODO: move this to DB, too
|
||||
// add bill to trader queue (if trader is enabled)
|
||||
if (traderPlugin) {
|
||||
tradesQueue.push({
|
||||
|
|
@ -258,8 +251,16 @@ exports.trade = function trade(deviceFingerprint, rawTrade, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
// record/log inserted bill
|
||||
db.recordBill(deviceFingerprint, rawTrade, cb);
|
||||
var tx = {
|
||||
txId: rawTrade.txId,
|
||||
toAddress: rawTrade.toAddress,
|
||||
currencyCode: rawTrade.currency
|
||||
};
|
||||
|
||||
async.parallel([
|
||||
async.apply(db.addPendingTx, deviceFingerprint, tx),
|
||||
async.apply(db.recordBill, deviceFingerprint, rawTrade)
|
||||
], cb);
|
||||
};
|
||||
|
||||
exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, cb) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue