Skip to content

Commit 8f6700d

Browse files
REFACTOR. pulling out chain tip query
1 parent 1c724ed commit 8f6700d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pycardano/backend/ogmios.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def _query_current_epoch(self) -> int:
100100
args = {"query": "currentEpoch"}
101101
return self._request(OgmiosQueryType.Query, args)
102102

103+
def _query_chain_tip(self) -> JSON:
104+
args = {"query": "chainTip"}
105+
return self._request(OgmiosQueryType.Query, args)["slot"]
106+
103107
def _check_chain_tip_and_update(self):
104108
slot = self.last_block_slot
105109
if self._last_known_block_slot != slot:
@@ -204,8 +208,8 @@ def epoch(self) -> int:
204208
@property
205209
def last_block_slot(self) -> int:
206210
"""Slot number of last block"""
207-
args = {"query": "chainTip"}
208-
return self._request(OgmiosQueryType.Query, args)["slot"]
211+
result = self._query_chain_tip()
212+
return result["slot"]
209213

210214
def _extract_asset_info(self, asset_hash: str) -> Tuple[str, ScriptHash, AssetName]:
211215
policy_hex, asset_name_hex = asset_hash.split(".")

0 commit comments

Comments
 (0)