use usual retry routine

This commit is contained in:
Daniel Lugo 2020-08-26 20:30:27 -04:00
parent 32b548a676
commit 8616e1fdef

View file

@ -979,30 +979,22 @@ const sendSpontaneousPayment = async (to, amount, memo, feeLimit) => {
throw new Error(msg) throw new Error(msg)
} }
/** @type {ReturnType<typeof setTimeout>} */ /** @type {import('shock-common').Schema.OrderResponse} */
// eslint-disable-next-line init-declarations const encryptedOrderRes = await Utils.tryAndWait(
let timeoutID gun =>
new Promise(res => {
/** gun
* @type {import('shock-common').Schema.OrderResponse}
*/
const encryptedOrderRes = await new Promise((res, rej) => {
require('../Mediator')
.getGun()
.user(to) .user(to)
.get(Key.ORDER_TO_RESPONSE) .get(Key.ORDER_TO_RESPONSE)
.get(orderID) .get(orderID)
.on(orderResponse => { .on(orderResponse => {
if (Schema.isOrderResponse(orderResponse)) { if (Schema.isOrderResponse(orderResponse)) {
clearTimeout(timeoutID)
res(orderResponse) res(orderResponse)
} }
}) })
}),
timeoutID = setTimeout(() => { v => !Schema.isOrderResponse(v)
rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME)) )
}, 20000)
})
/** @type {import('shock-common').Schema.OrderResponse} */ /** @type {import('shock-common').Schema.OrderResponse} */
const orderResponse = { const orderResponse = {