11"""
22Load all database records in the order:
3- 1. Retirements
4- 2. Sinking Transactions
5- 3. Minted Blocks
6- 4. Retirement from Block
7- 5. Sink Statuses
3+ 1. Impact Projects
4+ 2. Distribution Outflows
5+ 3. Sinking Transactions
6+ 4. Minted Blocks
7+ 5. Retirements
8+ 6. Retirement from Block
9+ 7. Sink Statuses
810
911Loading from scratch may fail if a Horizon instance with pruned history is selected.
1012You may select another instance with the SC_HORIZON_URL env variable.
1113
1214Author: Alex Olieman <https://keybase.io/alioli>
1315"""
1416import datetime as dt
17+ import sys
1518
1619from sc_audit .loader .distribution_outflows import load_distribution_txs
1720from sc_audit .loader .get_latest import get_latest_attr
21+ from sc_audit .loader .impact_projects import load_impact_projects
1822from sc_audit .loader .minted_blocks import load_minted_blocks
1923from sc_audit .loader .retirement_from_block import load_retirement_from_block
2024from sc_audit .loader .retirements import load_retirements
25+ from sc_audit .loader .sink_events import load_sink_events
2126from sc_audit .loader .sink_status import load_sink_statuses
2227from sc_audit .loader .sinking_txs import load_sinking_txs
28+ from sc_audit .sources .sink_events import MercuryError
2329
2430
2531def catch_up_from_sources ():
@@ -39,10 +45,19 @@ def catch_up_from_sources():
3945 ) # type: ignore[return-value]
4046
4147 print ("Started catch-up from data sources..." )
48+ num_impact_projects = load_impact_projects ()
49+ print (f"Loaded { num_impact_projects } impact projects" )
4250 num_distribution_txs = load_distribution_txs (cursor = dist_cursor )
4351 print (f"Loaded { num_distribution_txs } distribution outflows" )
4452 num_sinking_txs = load_sinking_txs (cursor = sink_cursor )
4553 print (f"Loaded { num_sinking_txs } sinking transactions" )
54+ try :
55+ num_sink_events = load_sink_events (cursor = sink_cursor ) # type: ignore[arg-type]
56+ print (f"Loaded { num_sink_events } sink events" )
57+ except MercuryError as exc :
58+ print (f"Couldn't load sink events from Mercury" )
59+ print (repr (exc ), file = sys .stderr )
60+
4661 num_minting_txs = load_minted_blocks (cursor = mint_cursor )
4762 print (f"Loaded { num_minting_txs } minted blocks" )
4863 num_retirements = load_retirements (from_date = retirement_date )
0 commit comments