mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 03:16:24 +00:00
Improve response time of confirm fiat receive; improve failure routing handling
This commit is contained in:
parent
b39529d91e
commit
3f6731d3e0
@ -49,7 +49,7 @@ class Logics():
|
|||||||
return False, {'bad_request':'You are already taker of an active order'}, queryset[0]
|
return False, {'bad_request':'You are already taker of an active order'}, queryset[0]
|
||||||
|
|
||||||
# Edge case when the user is in an order that is failing payment and he is the buyer
|
# Edge case when the user is in an order that is failing payment and he is the buyer
|
||||||
queryset = Order.objects.filter( Q(maker=user) | Q(taker=user), status__in=Order.Status.FAI)
|
queryset = Order.objects.filter( Q(maker=user) | Q(taker=user), status=Order.Status.FAI)
|
||||||
if queryset.exists():
|
if queryset.exists():
|
||||||
order = queryset[0]
|
order = queryset[0]
|
||||||
if cls.is_buyer(order, user):
|
if cls.is_buyer(order, user):
|
||||||
@ -794,13 +794,20 @@ class Logics():
|
|||||||
# RETURN THE BONDS // Probably best also do it even if payment failed
|
# RETURN THE BONDS // Probably best also do it even if payment failed
|
||||||
cls.return_bond(order.taker_bond)
|
cls.return_bond(order.taker_bond)
|
||||||
cls.return_bond(order.maker_bond)
|
cls.return_bond(order.maker_bond)
|
||||||
is_payed, context = follow_send_payment(order.payout) ##### !!! KEY LINE - PAYS THE BUYER INVOICE !!!
|
##### !!! KEY LINE - PAYS THE BUYER INVOICE !!!
|
||||||
if is_payed:
|
##### Backgroun process "follow_invoices" will try to pay this invoice until success
|
||||||
order.save()
|
order.status = Order.Status.PAY
|
||||||
return True, context
|
order.payout.status = LNPayment.Status.FLIGHT
|
||||||
else:
|
order.payout.save()
|
||||||
# error handling here
|
order.save()
|
||||||
return False, context
|
return True, None
|
||||||
|
# is_payed, context = follow_send_payment(order.payout) ##### !!! KEY LINE - PAYS THE BUYER INVOICE !!!
|
||||||
|
# if is_payed:
|
||||||
|
# order.save()
|
||||||
|
# return True, context
|
||||||
|
# else:
|
||||||
|
# # error handling here
|
||||||
|
# return False, context
|
||||||
else:
|
else:
|
||||||
return False, {'bad_request':'You cannot confirm the fiat payment at this stage'}
|
return False, {'bad_request':'You cannot confirm the fiat payment at this stage'}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.follow_hold_invoices()
|
self.follow_hold_invoices()
|
||||||
self.retry_payments()
|
self.send_payments()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if 'database is locked' in str(e):
|
if 'database is locked' in str(e):
|
||||||
self.stdout.write('database is locked')
|
self.stdout.write('database is locked')
|
||||||
@ -117,15 +117,25 @@ class Command(BaseCommand):
|
|||||||
self.stdout.write(str(timezone.now()))
|
self.stdout.write(str(timezone.now()))
|
||||||
self.stdout.write(str(debug))
|
self.stdout.write(str(debug))
|
||||||
|
|
||||||
def retry_payments(self):
|
def send_payments(self):
|
||||||
''' Checks if any payment is due for retry, and tries to pay it'''
|
'''
|
||||||
|
Checks for invoices that are due to pay; i.e., INFLIGHT status and 0 routing_attempts.
|
||||||
|
Checks if any payment is due for retry, and tries to pay it.
|
||||||
|
'''
|
||||||
|
|
||||||
queryset = LNPayment.objects.filter(type=LNPayment.Types.NORM,
|
queryset = LNPayment.objects.filter(type=LNPayment.Types.NORM,
|
||||||
|
status=LNPayment.Status.FLIGHT,
|
||||||
|
routing_attempts=0)
|
||||||
|
|
||||||
|
queryset_retries = LNPayment.objects.filter(type=LNPayment.Types.NORM,
|
||||||
status__in=[LNPayment.Status.VALIDI, LNPayment.Status.FAILRO],
|
status__in=[LNPayment.Status.VALIDI, LNPayment.Status.FAILRO],
|
||||||
routing_attempts__lt=4,
|
routing_attempts__lt=4,
|
||||||
last_routing_time__lt=(timezone.now()-timedelta(minutes=int(config('RETRY_TIME')))))
|
last_routing_time__lt=(timezone.now()-timedelta(minutes=int(config('RETRY_TIME')))))
|
||||||
|
|
||||||
|
queryset = queryset.union(queryset_retries)
|
||||||
|
|
||||||
for lnpayment in queryset:
|
for lnpayment in queryset:
|
||||||
success, _ = follow_send_payment(lnpayment)
|
success, _ = follow_send_payment(lnpayment) # Do follow_send_payment.delay() for further concurrency.
|
||||||
|
|
||||||
# If already 3 attempts and last failed. Make it expire (ask for a new invoice) an reset attempts.
|
# If already 3 attempts and last failed. Make it expire (ask for a new invoice) an reset attempts.
|
||||||
if not success and lnpayment.routing_attempts == 3:
|
if not success and lnpayment.routing_attempts == 3:
|
||||||
|
@ -77,7 +77,6 @@ def follow_send_payment(lnpayment):
|
|||||||
order.save()
|
order.save()
|
||||||
context = {'routing_failed': LNNode.payment_failure_context[response.failure_reason]}
|
context = {'routing_failed': LNNode.payment_failure_context[response.failure_reason]}
|
||||||
print(context)
|
print(context)
|
||||||
# Call a retry in 5 mins here?
|
|
||||||
return False, context
|
return False, context
|
||||||
|
|
||||||
if response.status == 2 : # Status 2 'SUCCEEDED'
|
if response.status == 2 : # Status 2 'SUCCEEDED'
|
||||||
|
@ -227,11 +227,9 @@ export default class BookPage extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Grid className='orderBook' container spacing={1} sx={{minWidth:400}}>
|
<Grid className='orderBook' container spacing={1} sx={{minWidth:400}}>
|
||||||
<Grid item xs={12} align="center">
|
{/* <Grid item xs={12} align="center">
|
||||||
<Typography component="h2" variant="h2">
|
<Typography component="h4" variant="h4">ORDER BOOK</Typography>
|
||||||
Order Book
|
</Grid> */}
|
||||||
</Typography>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Grid item xs={6} align="right">
|
<Grid item xs={6} align="right">
|
||||||
<FormControl >
|
<FormControl >
|
||||||
|
@ -153,12 +153,12 @@ export default class MakerPage extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Grid container xs={12} align="center" spacing={1}>
|
<Grid container xs={12} align="center" spacing={1} sx={{minWidth:380}}>
|
||||||
<Grid item xs={12} align="center" sx={{minWidth:380}}>
|
{/* <Grid item xs={12} align="center" sx={{minWidth:380}}>
|
||||||
<Typography component="h2" variant="h2">
|
<Typography component="h4" variant="h4">
|
||||||
Order Maker
|
ORDER MAKER
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid> */}
|
||||||
<Grid item xs={12} align="center" spacing={1}>
|
<Grid item xs={12} align="center" spacing={1}>
|
||||||
<Paper elevation={12} style={{ padding: 8, width:240, align:'center'}}>
|
<Paper elevation={12} style={{ padding: 8, width:240, align:'center'}}>
|
||||||
<Grid item xs={12} align="center" spacing={1}>
|
<Grid item xs={12} align="center" spacing={1}>
|
||||||
|
@ -67,16 +67,19 @@ body {
|
|||||||
filter: drop-shadow(0.5px 0.5px 0.5px #000000);
|
filter: drop-shadow(0.5px 0.5px 0.5px #000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
.phoneFlippedSmallAvatar {
|
.phoneFlippedSmallAvatar img{
|
||||||
transform: scaleX(-1);
|
transform: scaleX(-1);
|
||||||
border: 1.3px solid #555;
|
border: 1.3px solid #1976d2;
|
||||||
filter: drop-shadow(0.7px 0.7px 0.7px #000000);
|
-webkit-filter: grayscale(100%);
|
||||||
|
filter: grayscale(100%) brightness(150%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
.phoneFlippedSmallAvatar:after {
|
.phoneFlippedSmallAvatar:after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0; left: 0; bottom: 0; right: 0;
|
top: 0; left: 0; bottom: 0; right: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2.4px solid #1976d2;
|
||||||
box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
|
box-shadow: inset 0px 0px 35px rgb(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user