Skip to content

Commit

Permalink
Merge pull request #187 from saratomaz/query_slot_number
Browse files Browse the repository at this point in the history
Add helper function to 'query slot-number'
  • Loading branch information
mkoura committed Jun 14, 2023
2 parents 6f26a0d + 85a551d commit b237170
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cardano_clusterlib/query_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,5 +487,13 @@ def get_mempool_tx_exists(self, txid: str) -> Dict[str, Any]:
)
return tx_mempool

def get_slot_number(self, timestamp: datetime.datetime) -> int:
"""Return slot number for UTC timestamp."""
timestamp_str = timestamp.strftime("%Y-%m-%dT%H:%M:%SZ")

slot_number: int = json.loads(self.query_cli(["slot-number", timestamp_str]))

return slot_number

def __repr__(self) -> str:
return f"<{self.__class__.__name__}: clusterlib_obj={id(self._clusterlib_obj)}>"

0 comments on commit b237170

Please sign in to comment.