| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Pool.Relay
Description
Stake-pool relays with validated network-order addresses and DNS text. Ports and addresses may legitimately be absent.
SingleHostAddress Nothing Nothing Nothing represents an unspecified relay.
Synopsis
- data Ipv4
- ipv4FromBytes :: ByteString -> Either Error Ipv4
- ipv4Bytes :: Ipv4 -> ByteString
- ipv4FromText :: Text -> Either Error Ipv4
- ipv4Text :: Ipv4 -> Text
- data Ipv6
- ipv6FromBytes :: ByteString -> Either Error Ipv6
- ipv6Bytes :: Ipv6 -> ByteString
- ipv6FromText :: Text -> Either Error Ipv6
- ipv6Text :: Ipv6 -> Text
- data DnsName
- mkDnsName :: Text -> Either Error DnsName
- dnsNameText :: DnsName -> Text
- data Relay
- = SingleHostAddress !(Maybe Word16) !(Maybe Ipv4) !(Maybe Ipv6)
- | SingleHostName !(Maybe Word16) !DnsName
- | MultiHostName !DnsName
- encodeCbor :: Relay -> ByteString
- decodeCbor :: ByteString -> Either Error Relay
Documentation
IPv4 address in network byte order. Equality and ordering compare bytes.
ipv4FromBytes :: ByteString -> Either Error Ipv4 Source #
Validate an exact four-byte network-order IPv4 address.
Wrong lengths return InvalidPoolIpLength with expected and actual lengths.
ipv4Bytes :: Ipv4 -> ByteString Source #
Exact four-byte address.
ipv4FromText :: Text -> Either Error Ipv4 Source #
Parse four decimal octets, each 0 through 255, separated by dots.
Leading zeros are accepted; signs, whitespace and empty octets are rejected.
Malformed input returns InvalidPoolIpText with a diagnostic.
IPv6 address in network byte order. Equality and ordering compare bytes.
ipv6FromBytes :: ByteString -> Either Error Ipv6 Source #
Validate an exact sixteen-byte network-order IPv6 address.
ipv6Bytes :: Ipv6 -> ByteString Source #
Exact sixteen-byte address.
ipv6FromText :: Text -> Either Error Ipv6 Source #
Parse IPv6 hexadecimal groups, accepting a single :: compression and
an optional final dotted IPv4 address. Hexadecimal letter case is ignored;
signs, whitespace, repeated compression and incorrect group counts return
InvalidPoolIpText.
Relay DNS label, containing 1 through 64 UTF-8 bytes and no NUL. DNS syntax and reachability are not checked. Comparison uses text.
mkDnsName :: Text -> Either Error DnsName Source #
Validate 1 through 64 UTF-8 bytes and reject NUL, returning
InvalidPoolDnsName on either violation. DNS syntax is not checked.
dnsNameText :: DnsName -> Text Source #
Original DNS text.
Relay alternatives. Ordering follows CBOR codes, then constructor fields. Ports are unsigned 16-bit port numbers; absent fields encode as null.
Constructors
| SingleHostAddress !(Maybe Word16) !(Maybe Ipv4) !(Maybe Ipv6) | IP relay: optional port, IPv4 and IPv6. All may be absent. |
| SingleHostName !(Maybe Word16) !DnsName | A or AAAA DNS record, with optional port. |
| MultiHostName !DnsName | SRV DNS record; its port is supplied by DNS. |
encodeCbor :: Relay -> ByteString Source #
Fresh definite CBOR with shortest integer encodings. Re-encoding semantic data may change transaction identity.
decodeCbor :: ByteString -> Either Error Relay Source #
Decode the complete value. Definite or indefinite arrays and
nonminimal unsigned integers are accepted. All field bounds, arities, UTF-8
and trailing bytes are checked; violations return
InvalidPoolCbor. The original encoding is not retained.