feat: always set defaults with constants

This commit is contained in:
17ms 2024-07-12 23:16:07 +03:00
parent c4fbec3148
commit 59fb0d3a2a
Signed by untrusted user who does not match committer: ae
GPG Key ID: 995EFD5C1B532B3E
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import signal
import aioprocessing
from dotenv import load_dotenv
from src.const import DEFAULT_EXPORT_INTERVAL, DEFAULT_MODE
from src.mempool import WebSocketThread, QueueProcessor
from src.db import Handler, periodic_export
@ -42,10 +43,10 @@ def load_cfg(dotenv_path=".env"):
cfg["EXPORT_INTERVAL"] = os.getenv("EXPORT_INTERVAL")
if cfg["MODE"] is None:
cfg["MODE"] = "production"
cfg["MODE"] = DEFAULT_MODE
if cfg["EXPORT_INTERVAL"] is None:
cfg["EXPORT_INTERVAL"] = 24 * 60 * 60 # 24 hours in seconds
cfg["EXPORT_INTERVAL"] = DEFAULT_EXPORT_INTERVAL
else:
cfg["EXPORT_INTERVAL"] = int(cfg["EXPORT_INTERVAL"])

View File

@ -1,7 +1,10 @@
import json
DEFAULT_MODE = "production"
WS_ADDR = "wss://ws.blockchain.info/coins"
SUB_MSG = json.dumps({"coin": "eth", "command": "subscribe", "entity": "confirmed_transaction"})
WS_RECONNECT_PAUSE = 2 # Seconds
DEFAULT_EXPORT_PATH = "./data/export.json"
DEFAULT_EXPORT_INTERVAL = 10800 # 3 hours