aboutsummaryrefslogtreecommitdiff
path: root/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-19 21:22:29 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-19 21:22:29 +0100
commitaa37ef082d0e4aaedeb219d0a3f726da146edba7 (patch)
tree2d5ebc419cf9e261cfa025340ca01f37d568fdc1 /src/operations
parent0c9358c1b2bd80e25940022e86bd8daef8184ad7 (diff)
do normal back-off when reserve isn't ready yet, run retry-loop in integration test
Diffstat (limited to 'src/operations')
-rw-r--r--src/operations/pending.ts3
-rw-r--r--src/operations/reserves.ts14
2 files changed, 13 insertions, 4 deletions
diff --git a/src/operations/pending.ts b/src/operations/pending.ts
index ed3b59d71..f3cca9f24 100644
--- a/src/operations/pending.ts
+++ b/src/operations/pending.ts
@@ -37,7 +37,8 @@ function updateRetryDelay(
retryTimestamp: Timestamp,
): Duration {
const remaining = getDurationRemaining(retryTimestamp, now);
- return durationMin(oldDelay, remaining);
+ const nextDelay = durationMin(oldDelay, remaining);
+ return nextDelay;
}
async function gatherExchangePending(
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 2dedf17de..7f5c7d05f 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -53,6 +53,7 @@ import {
import {
guardOperationException,
OperationFailedAndReportedError,
+ OperationFailedError,
} from "./errors";
import { NotificationType } from "../types/notifications";
import { codecForReserveStatus } from "../types/ReserveStatus";
@@ -351,8 +352,11 @@ async function incrementReserveRetry(
if (!r.retryInfo) {
return;
}
+ console.log("updating retry info");
+ console.log("before", r.retryInfo);
r.retryInfo.retryCounter++;
updateRetryInfoTimeout(r.retryInfo);
+ console.log("after", r.retryInfo);
r.lastError = err;
await tx.put(Stores.reserves, r);
});
@@ -392,14 +396,18 @@ async function updateReserve(
resp = await ws.http.get(reqUrl.href);
console.log("got reserve/status response", await resp.json());
if (resp.status === 404) {
- const m = "The exchange does not know about this reserve (yet).";
- await incrementReserveRetry(ws, reservePub, undefined);
- return;
+ const m = "reserve not known to the exchange yet"
+ throw new OperationFailedError(m, {
+ type: "waiting",
+ message: m,
+ details: {},
+ });
}
if (resp.status !== 200) {
throw Error(`unexpected status code ${resp.status} for reserve/status`);
}
} catch (e) {
+ logger.trace("caught exception for reserve/status");
const m = e.message;
await incrementReserveRetry(ws, reservePub, {
type: "network",