This commit is contained in:
Josh Harvey 2016-12-08 23:06:48 +02:00
parent c3261bc61a
commit e24da06a1b
3 changed files with 64 additions and 38 deletions

View file

@ -19,7 +19,6 @@ const STALE_INCOMING_TX_AGE = T.week
const STALE_LIVE_INCOMING_TX_AGE = 10 * T.minutes
const MAX_NOTIFY_AGE = 2 * T.days
const MIN_NOTIFY_AGE = 5 * T.minutes
const TRANSACTION_EXPIRATION = 2 * T.days
const TRADE_TTL = 2 * T.minutes
const STALE_TICKER = 3 * T.minutes
const STALE_BALANCE = 3 * T.minutes
@ -158,17 +157,6 @@ function plugins (settings) {
})
}
function stateChange (deviceId, deviceTime, rec) {
const event = {
id: rec.uuid,
deviceId: deviceId,
eventType: 'stateChange',
note: JSON.stringify({state: rec.state, isIdle: rec.isIdle, txId: rec.txId}),
deviceTime: deviceTime
}
return dbm.machineEvent(event)
}
function recordPing (deviceId, deviceTime, rec) {
const event = {
id: uuid.v4(),
@ -453,23 +441,6 @@ function plugins (settings) {
.then(() => code)
}
function fetchPhoneTx (phone) {
return dbm.fetchPhoneTxs(phone, TRANSACTION_EXPIRATION)
.then(txs => {
const confirmedTxs = txs.filter(tx => R.contains(tx.status, ['instant', 'confirmed']))
if (confirmedTxs.length > 0) {
const maxTx = R.reduce((acc, val) => {
return !acc || val.cryptoAtoms.gt(acc.cryptoAtoms) ? val : acc
}, null, confirmedTxs)
return {tx: maxTx}
}
if (txs.length > 0) return {pending: true}
return {}
})
}
function sweepHD (row) {
const cryptoCode = row.crypto_code
@ -498,12 +469,10 @@ function plugins (settings) {
return {
pollQueries,
trade,
stateChange,
sendCoins,
cashOut,
dispenseAck,
getPhoneCode,
fetchPhoneTx,
executeTrades,
pong,
pongClear,