@@ -109,7 +109,7 @@ pAddressCmd =
109
109
Opt. subparser $
110
110
mconcat
111
111
[ Opt. command " key-gen"
112
- (Opt. info pAddressKeyGen $ Opt. progDesc " Create a single address key pair." )
112
+ (Opt. info pAddressKeyGen $ Opt. progDesc " Create an address key pair." )
113
113
, Opt. command " key-hash"
114
114
(Opt. info pAddressKeyHash $ Opt. progDesc " Print the hash of an address key to stdout." )
115
115
, Opt. command " build"
@@ -1251,24 +1251,78 @@ pPoolMargin =
1251
1251
maybeOrFail (Just mgn) = mgn
1252
1252
maybeOrFail Nothing = panic " Pool margin outside of [0,1] range."
1253
1253
1254
- _pPoolRelay :: Parser ShelleyStakePoolRelay
1255
- _pPoolRelay = Shelley. SingleHostAddr Shelley. SNothing
1256
- <$> (Shelley. maybeToStrictMaybe <$> optional _pIpV4)
1257
- <*> (Shelley. maybeToStrictMaybe <$> optional _pIpV6)
1258
-
1259
- _pIpV4 :: Parser IP. IPv4
1260
- _pIpV4 = Opt. option (Opt. maybeReader readMaybe :: Opt. ReadM IP. IPv4 )
1254
+ pPoolRelay :: Parser ShelleyStakePoolRelay
1255
+ pPoolRelay = pSingleHostAddress <|> pSingleHostName <|> pMultiHostName
1256
+
1257
+ pMultiHostName :: Parser ShelleyStakePoolRelay
1258
+ pMultiHostName =
1259
+ Shelley. MultiHostName <$> (Shelley. maybeToStrictMaybe <$> optional pPort) <*> pDNSName
1260
+ where
1261
+ pDNSName :: Parser Shelley. DnsName
1262
+ pDNSName = Opt. option (Opt. eitherReader eDNSName)
1263
+ ( Opt. long " multi-host-pool-relay"
1264
+ <> Opt. metavar " STRING"
1265
+ <> Opt. help " The stake pool relay's DNS name that corresponds to \
1266
+ \an SRV DNS record"
1267
+ )
1268
+
1269
+ pSingleHostName :: Parser ShelleyStakePoolRelay
1270
+ pSingleHostName =
1271
+ Shelley. SingleHostName <$> (Shelley. maybeToStrictMaybe <$> optional pPort) <*> pDNSName
1272
+ where
1273
+ pDNSName :: Parser Shelley. DnsName
1274
+ pDNSName = Opt. option (Opt. eitherReader eDNSName)
1275
+ ( Opt. long " single-host-pool-relay"
1276
+ <> Opt. metavar " STRING"
1277
+ <> Opt. help " The stake pool relay's DNS name that corresponds to an\
1278
+ \ A or AAAA DNS record"
1279
+ )
1280
+
1281
+ eDNSName :: String -> Either String Shelley. DnsName
1282
+ eDNSName str = maybe (Left " DNS name is more than 64 bytes" ) Right (Shelley. textToDns $ toS str)
1283
+
1284
+ pSingleHostAddress :: Parser ShelleyStakePoolRelay
1285
+ pSingleHostAddress =
1286
+ liftA3
1287
+ (\ port ip4 ip6 -> singleHostAddress port ip4 ip6)
1288
+ pPort
1289
+ (optional pIpV4)
1290
+ (optional pIpV6)
1291
+ where
1292
+ singleHostAddress :: Shelley. Port -> Maybe IP. IPv4 -> Maybe IP. IPv6 -> ShelleyStakePoolRelay
1293
+ singleHostAddress port ipv4 ipv6 =
1294
+ case (ipv4, ipv6) of
1295
+ (Nothing , Nothing ) ->
1296
+ panic $ " Please enter either an IPv4 or IPv6 address for the pool relay"
1297
+ (Just i4, Nothing ) ->
1298
+ Shelley. SingleHostAddr (Shelley. SJust port) (Shelley. SJust i4) Shelley. SNothing
1299
+ (Nothing , Just i6) ->
1300
+ Shelley. SingleHostAddr (Shelley. SJust port) Shelley. SNothing (Shelley. SJust i6)
1301
+ (Just i4, Just i6) ->
1302
+ Shelley. SingleHostAddr (Shelley. SJust port) (Shelley. SJust i4) (Shelley. SJust i6)
1303
+
1304
+
1305
+
1306
+ pIpV4 :: Parser IP. IPv4
1307
+ pIpV4 = Opt. option (Opt. maybeReader readMaybe :: Opt. ReadM IP. IPv4 )
1261
1308
( Opt. long " pool-relay-ipv4"
1262
1309
<> Opt. metavar " STRING"
1263
- <> Opt. help " The stake pool relay's IpV4 address"
1310
+ <> Opt. help " The stake pool relay's IPv4 address"
1264
1311
)
1265
1312
1266
- _pIpV6 :: Parser IP. IPv6
1267
- _pIpV6 = Opt. option (Opt. maybeReader readMaybe :: Opt. ReadM IP. IPv6 )
1268
- ( Opt. long " pool-relay-ipv6"
1269
- <> Opt. metavar " STRING"
1270
- <> Opt. help " The stake pool relay's IpV6 address"
1271
- )
1313
+ pIpV6 :: Parser IP. IPv6
1314
+ pIpV6 = Opt. option (Opt. maybeReader readMaybe :: Opt. ReadM IP. IPv6 )
1315
+ ( Opt. long " pool-relay-ipv6"
1316
+ <> Opt. metavar " STRING"
1317
+ <> Opt. help " The stake pool relay's IPv6 address"
1318
+ )
1319
+
1320
+ pPort :: Parser Shelley. Port
1321
+ pPort = Opt. option (fromInteger <$> Opt. eitherReader readEither)
1322
+ ( Opt. long " pool-relay-port"
1323
+ <> Opt. metavar " INT"
1324
+ <> Opt. help " The stake pool relay's port"
1325
+ )
1272
1326
1273
1327
pPoolMetaData :: Parser (Maybe ShelleyStakePoolMetaData )
1274
1328
pPoolMetaData =
@@ -1311,7 +1365,7 @@ pStakePoolRegistrationCert =
1311
1365
<*> pPoolMargin
1312
1366
<*> pRewardAcctVerificationKeyFile
1313
1367
<*> some pPoolOwner
1314
- <*> pure [] -- TODO: the relays
1368
+ <*> many pPoolRelay
1315
1369
<*> pPoolMetaData
1316
1370
<*> pNetwork
1317
1371
<*> pOutputFile
0 commit comments