Skip to content

Commit 320964d

Browse files
authored
Merge pull request #292 from input-output-hk/pass_tip
feat(query_group): add optional tip parameter to methods
2 parents 0ac48c2 + d326b88 commit 320964d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cardano_clusterlib/query_group.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,31 +391,37 @@ def get_leadership_schedule(
391391

392392
return schedule
393393

394-
def get_slot_no(self) -> int:
394+
def get_slot_no(self, tip: dict[str, tp.Any] | None = None) -> int:
395395
"""Return slot number of last block that was successfully applied to the ledger."""
396+
tip = tip or self.get_tip()
396397
return int(self.get_tip()["slot"])
397398

398-
def get_block_no(self) -> int:
399+
def get_block_no(self, tip: dict[str, tp.Any] | None = None) -> int:
399400
"""Return block number of last block that was successfully applied to the ledger."""
401+
tip = tip or self.get_tip()
400402
return int(self.get_tip()["block"])
401403

402-
def get_epoch(self) -> int:
404+
def get_epoch(self, tip: dict[str, tp.Any] | None = None) -> int:
403405
"""Return epoch of last block that was successfully applied to the ledger."""
406+
tip = tip or self.get_tip()
404407
return int(self.get_tip()["epoch"])
405408

406-
def get_epoch_slot_no(self) -> int:
409+
def get_epoch_slot_no(self, tip: dict[str, tp.Any] | None = None) -> int:
407410
"""Return slot number within a given epoch.
408411
409412
(of last block successfully applied to the ledger)
410413
"""
414+
tip = tip or self.get_tip()
411415
return int(self.get_tip()["slotInEpoch"])
412416

413-
def get_slots_to_epoch_end(self) -> int:
417+
def get_slots_to_epoch_end(self, tip: dict[str, tp.Any] | None = None) -> int:
414418
"""Return the number of slots left until the epoch end."""
419+
tip = tip or self.get_tip()
415420
return int(self.get_tip()["slotsToEpochEnd"])
416421

417-
def get_era(self) -> str:
422+
def get_era(self, tip: dict[str, tp.Any] | None = None) -> str:
418423
"""Return network era."""
424+
tip = tip or self.get_tip()
419425
era: str = self.get_tip()["era"]
420426
return era
421427

0 commit comments

Comments
 (0)