Last active
February 24, 2021 21:55
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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