WIPP
This commit is contained in:
parent
30071151ff
commit
15678530fd
3 changed files with 12 additions and 3 deletions
|
|
@ -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) {
|
function diff (oldTx, newTx) {
|
||||||
let updatedTx = {}
|
let updatedTx = {}
|
||||||
|
|
||||||
UPDATEABLE_FIELDS.forEach(fieldKey => {
|
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]
|
updatedTx[fieldKey] = newTx[fieldKey]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,6 @@ function plugins (settings, deviceId) {
|
||||||
// NOTE: This will fail if we have already sent coins because there will be
|
// NOTE: This will fail if we have already sent coins because there will be
|
||||||
// a unique dbm record in the table already.
|
// a unique dbm record in the table already.
|
||||||
function sendCoins (tx) {
|
function sendCoins (tx) {
|
||||||
console.log('DEBUG50: %j', settings)
|
|
||||||
return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
|
return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ function poll (req, res, next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function postTx (req, res, next) {
|
function postTx (req, res, next) {
|
||||||
console.log('DEBUG60: %j', req.settings)
|
|
||||||
const pi = plugins(req.settings, req.deviceId)
|
const pi = plugins(req.settings, req.deviceId)
|
||||||
|
|
||||||
return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)
|
return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue