B5: real deposits on the ORM, Electrum scan with quorum and merkle proof, configurable threshold (DEP-20..23, ELC-31)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f1d09075a1
commit
2acd4ccd1c
21 files changed
+1223
-49
No files matched your search
@@ -15,6 +15,29 @@ logger = logging.getLogger(__name__)
|
||||
TICK_SECONDS = 5
|
||||
|
||||
|
||||
_last_scan = 0.0
|
||||
SCAN_SECONDS = 10
|
||||
|
||||
|
||||
def scan_chain_deposits() -> None:
|
||||
"""DEP-20: every few seconds, on a real ledger only."""
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from apps.lottery import deposits
|
||||
from apps.lottery.electrum_chain import ElectrumChain
|
||||
|
||||
global _last_scan
|
||||
if time.monotonic() - _last_scan < SCAN_SECONDS:
|
||||
return
|
||||
_last_scan = time.monotonic()
|
||||
chain = ElectrumChain(settings.ELECTRUM_ENDPOINTS, settings.PLM_PROFILE, settings.ELECTRUM_ALLOW_NO_QUORUM)
|
||||
done = deposits.scan_deposits(chain)
|
||||
if any(done.values()):
|
||||
logger.info("deposit scan: %s", done)
|
||||
|
||||
|
||||
def tick() -> None:
|
||||
"""One pass over everything the worker is responsible for."""
|
||||
from django.conf import settings
|
||||
@@ -24,6 +47,8 @@ def tick() -> None:
|
||||
console.beat() # WEB-31: proof of life, before the work that might fail
|
||||
if settings.LEDGER_BACKEND == "simulated":
|
||||
simulation.settle()
|
||||
else:
|
||||
scan_chain_deposits() # B5
|
||||
lifecycle.tick()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user