From be5b32c4517d0a5c4b7164b514842ef01e9909c8 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 23 Jan 2022 13:12:30 -0800 Subject: [PATCH] Add retry time and lnpayment properties for routing failure --- .env-sample | 2 ++ api/views.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.env-sample b/.env-sample index 3eb14fbb..cfbb7a7a 100644 --- a/.env-sample +++ b/.env-sample @@ -21,6 +21,8 @@ FEE = 0.002 BOND_SIZE = 0.01 # Time out penalty for canceling takers in SECONDS PENALTY_TIMEOUT = 60 +# Time between routing attempts of buyer invoice in MINUTES +RETRY_TIME = 5 # Trade limits in satoshis MIN_TRADE = 10000 diff --git a/api/views.py b/api/views.py index f4c5d048..15601fa8 100644 --- a/api/views.py +++ b/api/views.py @@ -26,6 +26,7 @@ from decouple import config EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE')) FEE = float(config('FEE')) +RETRY_TIME = int(config('RETRY_TIME')) avatar_path = Path('frontend/static/assets/avatars') avatar_path.mkdir(parents=True, exist_ok=True) @@ -230,6 +231,11 @@ class OrderView(viewsets.ViewSet): data['statement_submitted'] = (order.maker_statement != None and order.maker_statement != "") elif data['is_taker']: data['statement_submitted'] = (order.taker_statement != None and order.maker_statement != "") + + # 9) If status is 'Failed routing', reply with retry amounts, time of next retry and ask for invoice at third. + elif order.status == Order.Status.FAI: + data['retries'] = order.buyer_invoice.routing_attempts + data['next_retry_time'] = order.buyer_invoice.last_routing_time + timedelta(minutes=RETRY_TIME) return Response(data, status.HTTP_200_OK)