fix(plugins) fix setTimeout args

This commit is contained in:
Josh Harvey 2014-11-13 12:33:19 -05:00
parent 8009cd04ac
commit ca8f9420af

View file

@ -270,7 +270,7 @@ function executeTx(deviceFingerprint, txId, triggeredByUser, cb) {
// indicate ACK to machine
cb(null, {
statusCode: 201, // Created
txId: txId
txId: txHash
});
});
});
@ -365,26 +365,27 @@ function _monitorTx(deviceFingerprint, tx) {
infoPlugin.getTx(tx.txHash, tx.toAddress, function(err, txInfo) {
if (err) {
logger.error(err);
return setTimeout(_monitorTx, 300, [deviceFingerprint, tx]);
return setTimeout(_monitorTx, 300, deviceFingerprint, tx);
}
if (_checkTx(deviceFingerprint, tx, txInfo))
return;
setTimeout(_monitorTx, 300, [deviceFingerprint, tx]);
setTimeout(_monitorTx, 300, deviceFingerprint, tx);
});
}
function _monitorAddress(deviceFingerprint, tx) {
if (!tx) throw new Error('No tx');
infoPlugin.getAddressLastTx(tx.toAddress, function(err, txInfo) {
if (err) {
logger.error(err);
return setTimeout(_monitorAddress, 300, [deviceFingerprint, tx]);
return setTimeout(_monitorAddress, 300, deviceFingerprint, tx);
}
// no tx occured at all or deposit address was reused; some previous tx was returned
if (!txInfo || txInfo.tsReceived < tx.created) {
return setTimeout(_monitorAddress, 300, [deviceFingerprint, tx]);
return setTimeout(_monitorAddress, 300, deviceFingerprint, tx);
}
// when sent TX is not enough
@ -406,7 +407,7 @@ function _monitorAddress(deviceFingerprint, tx) {
_setDispenseStatus(deviceFingerprint, tx, 'fullDeposit', txInfo.amount);
// start monitoring TX (instead of an address)
setTimeout(_monitorTx, 300, [deviceFingerprint, tx]);
setTimeout(_monitorTx, 300, deviceFingerprint, tx);
});
}