-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__init__.py
49 lines (35 loc) · 1.17 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import asyncio
from typing import List
from fastapi import APIRouter
from loguru import logger
from .crud import db
from .tasks import check_for_pending_swaps, wait_for_paid_invoices
from .views import boltz_generic_router
from .views_api import boltz_api_router
boltz_ext = APIRouter(prefix="/boltz", tags=["boltz"])
boltz_ext.include_router(boltz_generic_router)
boltz_ext.include_router(boltz_api_router)
boltz_static_files = [
{
"path": "/boltz/static",
"name": "boltz_static",
}
]
scheduled_tasks: List[asyncio.Task] = []
def boltz_stop():
for task in scheduled_tasks:
try:
task.cancel()
except Exception as ex:
logger.warning(ex)
def boltz_start():
from lnbits.tasks import create_permanent_unique_task, create_unique_task
pending_swaps = create_unique_task(
"ext_boltz_pending_swaps", check_for_pending_swaps()
)
scheduled_tasks.append(pending_swaps)
paid_invoices = create_permanent_unique_task(
"ext_boltz_paid_invoices", wait_for_paid_invoices
)
scheduled_tasks.append(paid_invoices)
__all__ = ["boltz_ext", "boltz_static_files", "boltz_start", "boltz_stop", "db"]