Skip to content

Instantly share code, notes, and snippets.

@NotoriousPyro
Last active February 24, 2021 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotoriousPyro/6a0670ed19a6f13b61aa0cf7d0df4e85 to your computer and use it in GitHub Desktop.
Save NotoriousPyro/6a0670ed19a6f13b61aa0cf7d0df4e85 to your computer and use it in GitHub Desktop.
Builds a topology for use with cardano-node. Set your own block producing relays inside the $newRelays object. Only looks for relays with addresses like *relays* but you can easily customise it. Creates a file called mainnet-topology.json
$relays = Invoke-WebRequest -Uri https://explorer.mainnet.cardano.org/relays/topology.json | ConvertFrom-Json
$relays2 = $relays.Producers | Where-Object {
$_.addr -like '*relays*'
} | Sort-Object { $_.addr -eq 'relays-new.cardano-mainnet.iohk.io' } -Descending
$newRelays = @{
"Producers" = [Collections.ArrayList]@(
@{
"addr" = "127.0.0.1"
"port" = 8000
"valency" = 1
}
)
}
foreach ($relay in $relays2) {
$valency = (Resolve-DnsName $relay.addr).Count
$newRelays.Producers.Add(
@{
"addr" = $relay.addr
"port" = $relay.port
"valency" = $valency
}
) | Out-Null
}
$newRelays | ConvertTo-Json | Out-File mainnet-topology.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment