Skip to content

Commit

Permalink
fix: better debug logging for receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
emschwartz committed Aug 15, 2017
1 parent 3fb2306 commit a05f904
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function _accountToSharedSecret ({ account, pluginAccount, receiverSecret }) {
}

function _reject (plugin, id, reason) {
debug('rejecting incoming transfer:', id, reason)
return plugin
.rejectIncomingTransfer(id, Object.assign({
triggered_by: plugin.getAccount(),
Expand Down Expand Up @@ -190,6 +191,7 @@ function * _autoFulfillCondition ({
if (transfer.executionCondition !== cryptoHelper.preimageToCondition(preimage)) {
debug('notified of transfer where executionCondition does not' +
' match the one we generate.' +
' transfer.id=' + transfer.id +
' executionCondition=' + transfer.executionCondition +
' our condition=' + cryptoHelper.preimageToCondition(preimage))
return yield _reject(plugin, transfer.id, {
Expand All @@ -201,6 +203,7 @@ function * _autoFulfillCondition ({

const fulfillment = cryptoHelper.preimageToFulfillment(preimage)

debug('calling callback to review transfer:', transfer, details)
try {
yield Promise.resolve(callback({
transfer: transfer,
Expand All @@ -212,7 +215,10 @@ function * _autoFulfillCondition ({
fulfillment,
fulfill: function () {
return retryPromise({
callback: () => plugin.fulfillCondition(transfer.id, fulfillment),
callback: () => {
debug('fulfilling transfer:', transfer.id, 'with fulfillment:', fulfillment)
return plugin.fulfillCondition(transfer.id, fulfillment)
},
minWait: minFulfillRetryWait || DEFAULT_MIN_FULFILL_RETRY_WAIT,
maxWait: maxFulfillRetryWait || DEFAULT_MAX_FULFILL_RETRY_WAIT,
stopWaiting: (new Date(transfer.expiresAt))
Expand All @@ -221,6 +227,7 @@ function * _autoFulfillCondition ({
}))
} catch (e) {
// reject immediately and pass the error if review rejects
debug('error in review callback for transfer:', transfer.id, e)

return _reject(plugin, transfer.id, {
code: 'S00',
Expand Down

0 comments on commit a05f904

Please sign in to comment.