From 3848d0245066f156e33a4bd568a62521b4d1ac84 Mon Sep 17 00:00:00 2001 From: Max Kurapov Date: Mon, 2 Dec 2024 16:59:31 +0100 Subject: [PATCH] feat(backend): use cache when fetching outgoing payment in worker --- .../src/open_payments/payment/outgoing/worker.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/open_payments/payment/outgoing/worker.ts b/packages/backend/src/open_payments/payment/outgoing/worker.ts index a2e688036f..05631aa7b7 100644 --- a/packages/backend/src/open_payments/payment/outgoing/worker.ts +++ b/packages/backend/src/open_payments/payment/outgoing/worker.ts @@ -75,7 +75,7 @@ async function getPendingPayment( [RETRY_BACKOFF_SECONDS, now] ) }) - .withGraphFetched('[walletAddress, quote.asset]') + .withGraphFetched('quote') stopTimer() return payments[0] } @@ -89,6 +89,16 @@ async function handlePaymentLifecycle( return } + const [paymentWalletAddress, quoteAsset] = await Promise.all([ + deps.walletAddressService.get(payment.walletAddressId), + deps.assetService.get(payment.quote.assetId) + ]) + + payment.walletAddress = paymentWalletAddress + if (quoteAsset) { + payment.quote.asset = quoteAsset + } + const stopTimer = deps.telemetry.startTimer('handle_sending_ms', { callName: 'OutoingPaymentWorker:handleSending' })