use usual retry routine
This commit is contained in:
parent
32b548a676
commit
8616e1fdef
1 changed files with 16 additions and 24 deletions
|
|
@ -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}
|
.user(to)
|
||||||
*/
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
const encryptedOrderRes = await new Promise((res, rej) => {
|
.get(orderID)
|
||||||
require('../Mediator')
|
.on(orderResponse => {
|
||||||
.getGun()
|
if (Schema.isOrderResponse(orderResponse)) {
|
||||||
.user(to)
|
res(orderResponse)
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
}
|
||||||
.get(orderID)
|
})
|
||||||
.on(orderResponse => {
|
}),
|
||||||
if (Schema.isOrderResponse(orderResponse)) {
|
v => !Schema.isOrderResponse(v)
|
||||||
clearTimeout(timeoutID)
|
)
|
||||||
res(orderResponse)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
timeoutID = setTimeout(() => {
|
|
||||||
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 = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue