From ca8f9420afce41bd8d80185d65a02a3ec014f05c Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Thu, 13 Nov 2014 12:33:19 -0500 Subject: [PATCH] fix(plugins) fix setTimeout args --- lib/plugins.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index 2ebe3dc0..1c539a1a 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -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); }); }