Skip to content

Commit ce8a520

Browse files
committed
prune state at initial height
1 parent 3ccbd56 commit ce8a520

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

utxo_indexer/indexer/indexer_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
TipSyncStateChoices,
1515
UtxoBlock,
1616
)
17+
from utxo_indexer.models.sync_state import PruneSyncState
1718
from utxo_indexer.models.types import BlockResponse
1819

1920
from .decorators import retry
@@ -133,6 +134,8 @@ def run(self) -> None:
133134
Runs the indexing process in a endless loop
134135
"""
135136
logger.info("Starting the indexer")
137+
# Make sure prune state is initialized
138+
self.initialize_bottom_state()
136139
while True:
137140
self.ensure_workers()
138141
assert self.toplevel_worker is not None, "Toplevel worker should be connected and defined"
@@ -219,6 +222,14 @@ def update_tip_state_done_block_process(self, indexed_block_height: int):
219222
tip_state.timestamp = int(time.time())
220223
tip_state.save()
221224

225+
# Bottom/Prune state managment
226+
def initialize_bottom_state(self):
227+
prune_state = PruneSyncState.instance()
228+
prune_state.timestamp = int(time.time())
229+
if prune_state.latest_indexed_tail_height == 0:
230+
prune_state.latest_indexed_tail_height = self.latest_indexed_block_height
231+
prune_state.save()
232+
222233
def process_block(self, block_height: int):
223234
"""
224235
Process the block with given height

utxo_indexer/migrations/0003_version_delete_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('utxo_indexer', '0002_version'),
9+
('utxo_indexer', '0002_config'),
1010
]
1111

1212
operations = [

0 commit comments

Comments
 (0)