SingleHostAddrRelay

class cometa.pool_params.single_host_addr_relay.SingleHostAddrRelay(ptr)[source]

Bases: object

Represents a single host address relay for Cardano stake pools.

This relay type points to a single host via its IPv4/IPv6 address and a given port. At least one of IPv4 or IPv6 address should be provided. The port is optional.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

SingleHostAddrRelay

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(port=None, ipv4=None, ipv6=None)[source]

Creates a new single host address relay.

Parameters:
  • port (int | None) – Optional port number (0-65535).

  • ipv4 (IPv4 | None) – Optional IPv4 address.

  • ipv6 (IPv6 | None) – Optional IPv6 address.

Returns:

A new SingleHostAddrRelay instance.

Raises:

CardanoError – If creation fails.

Return type:

SingleHostAddrRelay

Example

>>> ipv4 = IPv4.from_string("192.168.1.1")
>>> relay = SingleHostAddrRelay.new(port=3001, ipv4=ipv4)
classmethod from_cbor(reader)[source]

Deserializes a SingleHostAddrRelay from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the relay data.

Returns:

A new SingleHostAddrRelay deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

SingleHostAddrRelay

to_cbor(writer)[source]

Serializes the relay to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

property port: int | None

Returns the port number, or None if not set.

property ipv4: IPv4 | None

Returns the IPv4 address, or None if not set.

property ipv6: IPv6 | None

Returns the IPv6 address, or None if not set.

to_cip116_json(writer)[source]

Serializes this relay to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None