diff --git a/.env-sample b/.env-sample index ae56b081..8358a173 100644 --- a/.env-sample +++ b/.env-sample @@ -58,6 +58,9 @@ PENALTY_TIMEOUT = 60 # Time between routing attempts of buyer invoice in MINUTES RETRY_TIME = 5 +# Platform activity limits +MAX_PUBLIC_ORDERS = 100 + # Trade limits in satoshis MIN_TRADE = 10000 MAX_TRADE = 500000 diff --git a/api/views.py b/api/views.py index 2a2923fc..925049e3 100644 --- a/api/views.py +++ b/api/views.py @@ -55,6 +55,16 @@ class MakerView(CreateAPIView): if not serializer.is_valid(): return Response(status=status.HTTP_400_BAD_REQUEST) + # In case it gets overwhelming. Limit the number of public orders. + if Order.objects.filter(status=Order.Status.PUB).count() >= int(config("MAX_PUBLIC_ORDERS")): + return Response( + { + "bad_request": + "Woah! RoboSats' book is at full capacity! Try again later" + }, + status.HTTP_400_BAD_REQUEST, + ) + type = serializer.data.get("type") currency = serializer.data.get("currency") amount = serializer.data.get("amount")