Files
plm-lottery/app/rounds/config.py
T
davideandClaude Sonnet 5 5ce49d7b88 Add round lifecycle, draw algorithm and scheduler
Periodic scheduler (configurable round duration) that closes a round
only once all broadcast bets confirm, waits for the next block after
closing, draws a winner via block-hash-seeded modulo over participants
ordered by broadcast time, triggers the 70/30 payout, and only opens the
next round once that payout confirms. Draw logic is isolated in
draw.py as a deliberately simple, replaceable component.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-21 10:26:18 +02:00

18 lines
683 B
Python

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.config import settings
from app.db.models import RoundConfig
async def get_round_config(session: AsyncSession) -> RoundConfig:
"""Single-row operational config, lazily seeded from settings defaults on
first use. fee_address starts empty until an operator sets it (admin
endpoint, stage 10) — payouts must refuse to run until it's set."""
config = await session.scalar(select(RoundConfig))
if config is None:
config = RoundConfig(fee_address="", bet_amount_sats=settings.bet_amount_sats)
session.add(config)
await session.flush()
return config