feat: always set defaults with constants
This commit is contained in:
parent
c4fbec3148
commit
59fb0d3a2a
5
main.py
5
main.py
@ -8,6 +8,7 @@ import signal
|
|||||||
import aioprocessing
|
import aioprocessing
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
from src.const import DEFAULT_EXPORT_INTERVAL, DEFAULT_MODE
|
||||||
from src.mempool import WebSocketThread, QueueProcessor
|
from src.mempool import WebSocketThread, QueueProcessor
|
||||||
from src.db import Handler, periodic_export
|
from src.db import Handler, periodic_export
|
||||||
|
|
||||||
@ -42,10 +43,10 @@ def load_cfg(dotenv_path=".env"):
|
|||||||
cfg["EXPORT_INTERVAL"] = os.getenv("EXPORT_INTERVAL")
|
cfg["EXPORT_INTERVAL"] = os.getenv("EXPORT_INTERVAL")
|
||||||
|
|
||||||
if cfg["MODE"] is None:
|
if cfg["MODE"] is None:
|
||||||
cfg["MODE"] = "production"
|
cfg["MODE"] = DEFAULT_MODE
|
||||||
|
|
||||||
if cfg["EXPORT_INTERVAL"] is None:
|
if cfg["EXPORT_INTERVAL"] is None:
|
||||||
cfg["EXPORT_INTERVAL"] = 24 * 60 * 60 # 24 hours in seconds
|
cfg["EXPORT_INTERVAL"] = DEFAULT_EXPORT_INTERVAL
|
||||||
else:
|
else:
|
||||||
cfg["EXPORT_INTERVAL"] = int(cfg["EXPORT_INTERVAL"])
|
cfg["EXPORT_INTERVAL"] = int(cfg["EXPORT_INTERVAL"])
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
DEFAULT_MODE = "production"
|
||||||
|
|
||||||
WS_ADDR = "wss://ws.blockchain.info/coins"
|
WS_ADDR = "wss://ws.blockchain.info/coins"
|
||||||
SUB_MSG = json.dumps({"coin": "eth", "command": "subscribe", "entity": "confirmed_transaction"})
|
SUB_MSG = json.dumps({"coin": "eth", "command": "subscribe", "entity": "confirmed_transaction"})
|
||||||
WS_RECONNECT_PAUSE = 2 # Seconds
|
WS_RECONNECT_PAUSE = 2 # Seconds
|
||||||
|
|
||||||
DEFAULT_EXPORT_PATH = "./data/export.json"
|
DEFAULT_EXPORT_PATH = "./data/export.json"
|
||||||
|
DEFAULT_EXPORT_INTERVAL = 10800 # 3 hours
|
||||||
|
Loading…
Reference in New Issue
Block a user