adding a fixed exchange rate for the dollar to the ruble/fixing server failures
This commit is contained in:
@@ -107,10 +107,10 @@ async def renew_on_3xui(
|
||||
continue
|
||||
if SUPERNODE:
|
||||
unique_email = f"{email}_{server_name.lower()}"
|
||||
sub_id_val = email if update_links else None
|
||||
sub_id_val = email
|
||||
else:
|
||||
unique_email = email
|
||||
sub_id_val = unique_email if update_links else None
|
||||
sub_id_val = unique_email
|
||||
traffic_bytes = total_gb * 1024 * 1024 * 1024 if total_gb else 0
|
||||
|
||||
async def process_server(si, inbound, uniq, sub, name):
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Optional, Tuple
|
||||
import time
|
||||
from decimal import ROUND_HALF_UP, Decimal
|
||||
import aiohttp
|
||||
from config import MULTICURRENCY_ENABLE, FX_MARKUP
|
||||
from config import MULTICURRENCY_ENABLE, FX_MARKUP, RUB_TO_USD
|
||||
|
||||
|
||||
CBR_URL = "https://www.cbr-xml-daily.ru/daily_json.js"
|
||||
@@ -33,15 +33,15 @@ async def to_rub(amount: float | Decimal, base: str, *, session: aiohttp.ClientS
|
||||
|
||||
|
||||
async def get_rub_rate(quote: str, *, session: aiohttp.ClientSession | None = None) -> Decimal:
|
||||
"""
|
||||
Возвращает курс 'QUOTE per RUB' (сколько единиц валюты QUOTE приходится на 1 рубль).
|
||||
Пример: для USD при 100 RUB за 1 USD вернёт 0.01 USD/RUB.
|
||||
Здесь же применяется наценка FX_MARKUP (если задана и валюта не RUB).
|
||||
"""
|
||||
code = quote.upper()
|
||||
if code == "RUB":
|
||||
return Decimal("1")
|
||||
|
||||
if code == "USD" and RUB_TO_USD not in (False, None, 0):
|
||||
rate = _q(Decimal("1") / Decimal(str(RUB_TO_USD)))
|
||||
cache[code] = (time.time(), rate)
|
||||
return rate
|
||||
|
||||
now = time.time()
|
||||
cached = cache.get(code)
|
||||
if cached and now - cached[0] < CACHE_TTL:
|
||||
|
||||
Reference in New Issue
Block a user