Relay

class cometa.pool_params.relay.Relay(ptr)[source]

Bases: object

Represents a generic relay for Cardano stake pools.

A relay is a type of node that acts as an intermediary between core nodes (which produce blocks) and the wider internet. They help in passing along transactions and blocks, ensuring that data is propagated throughout the network.

This class wraps the three specific relay types: - SingleHostAddrRelay: Connects via IPv4/IPv6 address and port - SingleHostNameRelay: Connects via DNS name and port - MultiHostNameRelay: Connects via DNS SRV record

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

Relay

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod from_single_host_addr(relay)[source]

Creates a Relay from a SingleHostAddrRelay.

Parameters:

relay (SingleHostAddrRelay) – The single host address relay.

Returns:

A new Relay wrapping the single host address relay.

Raises:

CardanoError – If creation fails.

Return type:

Relay

classmethod from_single_host_name(relay)[source]

Creates a Relay from a SingleHostNameRelay.

Parameters:

relay (SingleHostNameRelay) – The single host name relay.

Returns:

A new Relay wrapping the single host name relay.

Raises:

CardanoError – If creation fails.

Return type:

Relay

classmethod from_multi_host_name(relay)[source]

Creates a Relay from a MultiHostNameRelay.

Parameters:

relay (MultiHostNameRelay) – The multi-host name relay.

Returns:

A new Relay wrapping the multi-host name relay.

Raises:

CardanoError – If creation fails.

Return type:

Relay

classmethod from_cbor(reader)[source]

Deserializes a Relay from CBOR data.

Parameters:

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

Returns:

A new Relay deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

Relay

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 relay_type: RelayType

Returns the type of this relay.

to_single_host_addr()[source]

Converts this relay to a SingleHostAddrRelay.

Returns:

The underlying SingleHostAddrRelay.

Raises:

CardanoError – If this relay is not a single host address relay.

Return type:

SingleHostAddrRelay

to_single_host_name()[source]

Converts this relay to a SingleHostNameRelay.

Returns:

The underlying SingleHostNameRelay.

Raises:

CardanoError – If this relay is not a single host name relay.

Return type:

SingleHostNameRelay

to_multi_host_name()[source]

Converts this relay to a MultiHostNameRelay.

Returns:

The underlying MultiHostNameRelay.

Raises:

CardanoError – If this relay is not a multi-host name relay.

Return type:

MultiHostNameRelay

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