Skip to content

Commit f21348f

Browse files
Merge pull request #398 from theeldermillenial/feat/ogmios-path
Add path to Ogmios v6 backend
2 parents 7092382 + 8abf39c commit f21348f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pycardano/backend/ogmios_v6.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
self,
5858
host: str = "localhost",
5959
port: int = 1337,
60+
path: str = "",
6061
secure: bool = False,
6162
refetch_chain_tip_interval: Optional[float] = None,
6263
utxo_cache_size: int = 10000,
@@ -65,6 +66,7 @@ def __init__(
6566
):
6667
self.host = host
6768
self.port = port
69+
self.path = path
6870
self.secure = secure
6971
self._network = network
7072
self._service_name = "ogmios"
@@ -84,26 +86,26 @@ def __init__(
8486
self._datum_cache = LRUCache(maxsize=datum_cache_size)
8587

8688
def _query_current_era(self) -> OgmiosEra:
87-
with OgmiosClient(self.host, self.port, self.secure) as client:
89+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
8890
return get_current_era(client)
8991

9092
def _query_current_epoch(self) -> int:
91-
with OgmiosClient(self.host, self.port, self.secure) as client:
93+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
9294
epoch, _ = client.query_epoch.execute()
9395
return epoch
9496

9597
def _query_chain_tip(self) -> OgmiosTip:
96-
with OgmiosClient(self.host, self.port, self.secure) as client:
98+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
9799
tip, _ = client.query_network_tip.execute()
98100
return tip
99101

100102
def _query_utxos_by_address(self, address: Address) -> List[OgmiosUtxo]:
101-
with OgmiosClient(self.host, self.port, self.secure) as client:
103+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
102104
utxos, _ = client.query_utxo.execute([address])
103105
return utxos
104106

105107
def _query_utxos_by_tx_id(self, tx_id: str, index: int) -> List[OgmiosUtxo]:
106-
with OgmiosClient(self.host, self.port, self.secure) as client:
108+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
107109
utxos, _ = client.query_utxo.execute(
108110
[OgmiosTxOutputReference(tx_id, index)]
109111
)
@@ -133,7 +135,7 @@ def protocol_param(self) -> ProtocolParameters:
133135
return self._protocol_param
134136

135137
def _fetch_protocol_param(self) -> ProtocolParameters:
136-
with OgmiosClient(self.host, self.port, self.secure) as client:
138+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
137139
protocol_parameters, _ = client.query_protocol_parameters.execute()
138140
pyc_protocol_params = ProtocolParameters(
139141
min_fee_constant=protocol_parameters.min_fee_constant.lovelace,
@@ -203,7 +205,7 @@ def genesis_param(self) -> GenesisParameters:
203205
return self._genesis_param # type: ignore[return-value]
204206

205207
def _fetch_genesis_param(self) -> OgmiosGenesisParameters:
206-
with OgmiosClient(self.host, self.port, self.secure) as client:
208+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
207209
return OgmiosGenesisParameters(client, self._query_current_era())
208210

209211
@property
@@ -308,13 +310,13 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
308310
def submit_tx_cbor(self, cbor: Union[bytes, str]):
309311
if isinstance(cbor, bytes):
310312
cbor = cbor.hex()
311-
with OgmiosClient(self.host, self.port, self.secure) as client:
313+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
312314
client.submit_transaction.execute(cbor)
313315

314316
def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits]:
315317
if isinstance(cbor, bytes):
316318
cbor = cbor.hex()
317-
with OgmiosClient(self.host, self.port, self.secure) as client:
319+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
318320
result, _ = client.evaluate_transaction.execute(cbor)
319321
result_dict = {}
320322
for res in result:
@@ -363,6 +365,7 @@ class OgmiosChainContext(OgmiosV6ChainContext):
363365
def KupoOgmiosV6ChainContext(
364366
host: str,
365367
port: int,
368+
path: str,
366369
secure: bool,
367370
refetch_chain_tip_interval: Optional[float] = None,
368371
utxo_cache_size: int = 10000,
@@ -374,6 +377,7 @@ def KupoOgmiosV6ChainContext(
374377
OgmiosV6ChainContext(
375378
host,
376379
port,
380+
path,
377381
secure,
378382
refetch_chain_tip_interval,
379383
utxo_cache_size,

0 commit comments

Comments
 (0)