This commit is contained in:
Josh Harvey 2017-03-06 16:07:00 +02:00
parent 30071151ff
commit 15678530fd
3 changed files with 12 additions and 3 deletions

View file

@ -30,11 +30,22 @@ function post (tx, pi) {
})
}
function nilEqual (a, b) {
if (_.isNil(a) && _.isNil(b)) return true
return undefined
}
function diff (oldTx, newTx) {
let updatedTx = {}
UPDATEABLE_FIELDS.forEach(fieldKey => {
if (oldTx && _.isEqual(oldTx[fieldKey], newTx[fieldKey])) return
console.log('DEBUG80: %j', [oldTx[fieldKey], newTx[fieldKey]])
if (oldTx && _.isEqualWith(nilEqual, oldTx[fieldKey], newTx[fieldKey])) return
// We never null out an existing field
if (oldTx && _.isNil(newTx[fieldKey])) return
updatedTx[fieldKey] = newTx[fieldKey]
})

View file

@ -136,7 +136,6 @@ function plugins (settings, deviceId) {
// NOTE: This will fail if we have already sent coins because there will be
// a unique dbm record in the table already.
function sendCoins (tx) {
console.log('DEBUG50: %j', settings)
return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
}

View file

@ -79,7 +79,6 @@ function poll (req, res, next) {
}
function postTx (req, res, next) {
console.log('DEBUG60: %j', req.settings)
const pi = plugins(req.settings, req.deviceId)
return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)