Implement max public orders limit

This commit is contained in:
Reckless_Satoshi 2022-02-25 12:08:22 -08:00
parent 67a108e0ac
commit fba6749500
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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")