@@ -18,93 +18,109 @@ import "github.com/blinklabs-io/gouroboros/ledger/common"
1818
1919// Network definitions
2020var (
21- NetworkTestnet = Network {
22- Id : common .AddressNetworkTestnet ,
23- Name : "testnet" ,
24- NetworkMagic : 1097911063 ,
25- }
2621 NetworkMainnet = Network {
27- Id : common .AddressNetworkMainnet ,
28- Name : "mainnet" ,
29- NetworkMagic : 764824073 ,
30- PublicRootAddress : "backbone.cardano.iog.io" ,
31- PublicRootPort : 3001 ,
22+ Id : common .AddressNetworkMainnet ,
23+ Name : "mainnet" ,
24+ NetworkMagic : 764824073 ,
25+ BootstrapPeers : []NetworkBootstrapPeer {
26+ {
27+ Address : "backbone.cardano.iog.io" ,
28+ Port : 3001 ,
29+ },
30+ {
31+ Address : "backbone.mainnet.emurgornd.com" ,
32+ Port : 3001 ,
33+ },
34+ {
35+ Address : "backbone.mainnet.cardanofoundation.org" ,
36+ Port : 3001 ,
37+ },
38+ },
3239 }
3340 NetworkPreprod = Network {
34- Id : common .AddressNetworkTestnet ,
35- Name : "preprod" ,
36- NetworkMagic : 1 ,
37- PublicRootAddress : "preprod-node.world.dev.cardano.org" ,
38- PublicRootPort : 30000 ,
41+ Id : common .AddressNetworkTestnet ,
42+ Name : "preprod" ,
43+ NetworkMagic : 1 ,
44+ BootstrapPeers : []NetworkBootstrapPeer {
45+ {
46+ Address : "preprod-node.play.dev.cardano.org" ,
47+ Port : 3001 ,
48+ },
49+ },
3950 }
4051 NetworkPreview = Network {
41- Id : common .AddressNetworkTestnet ,
42- Name : "preview" ,
43- NetworkMagic : 2 ,
44- PublicRootAddress : "preview-node.play.dev.cardano.org" ,
45- PublicRootPort : 3001 ,
52+ Id : common .AddressNetworkTestnet ,
53+ Name : "preview" ,
54+ NetworkMagic : 2 ,
55+ BootstrapPeers : []NetworkBootstrapPeer {
56+ {
57+ Address : "preview-node.play.dev.cardano.org" ,
58+ Port : 3001 ,
59+ },
60+ },
4661 }
4762 NetworkSancho = Network {
48- Id : common .AddressNetworkTestnet ,
49- Name : "sanchonet" ,
50- NetworkMagic : 4 ,
51- PublicRootAddress : "sanchonet-node.play.dev.cardano.org" ,
52- PublicRootPort : 3001 ,
63+ Id : common .AddressNetworkTestnet ,
64+ Name : "sanchonet" ,
65+ NetworkMagic : 4 ,
66+ BootstrapPeers : []NetworkBootstrapPeer {
67+ {
68+ Address : "sanchonet-node.play.dev.cardano.org" ,
69+ Port : 3001 ,
70+ },
71+ },
5372 }
54-
55- NetworkInvalid = Network {
56- Id : 0 ,
57- Name : "invalid" ,
58- NetworkMagic : 0 ,
59- } // NetworkInvalid is used as a return value for lookup functions when a network isn't found
6073)
6174
6275// List of valid networks for use in lookup functions
6376var networks = []Network {
64- NetworkTestnet ,
6577 NetworkMainnet ,
6678 NetworkPreprod ,
6779 NetworkPreview ,
6880 NetworkSancho ,
6981}
7082
7183// NetworkByName returns a predefined network by name
72- func NetworkByName (name string ) Network {
84+ func NetworkByName (name string ) ( Network , bool ) {
7385 for _ , network := range networks {
7486 if network .Name == name {
75- return network
87+ return network , true
7688 }
7789 }
78- return NetworkInvalid
90+ return Network {}, false
7991}
8092
8193// NetworkById returns a predefined network by ID
82- func NetworkById (id uint8 ) Network {
94+ func NetworkById (id uint8 ) ( Network , bool ) {
8395 for _ , network := range networks {
8496 if network .Id == id {
85- return network
97+ return network , true
8698 }
8799 }
88- return NetworkInvalid
100+ return Network {}, false
89101}
90102
91103// NetworkByNetworkMagic returns a predefined network by network magic
92- func NetworkByNetworkMagic (networkMagic uint32 ) Network {
104+ func NetworkByNetworkMagic (networkMagic uint32 ) ( Network , bool ) {
93105 for _ , network := range networks {
94106 if network .NetworkMagic == networkMagic {
95- return network
107+ return network , true
96108 }
97109 }
98- return NetworkInvalid
110+ return Network {}, false
99111}
100112
101113// Network represents a Cardano network
102114type Network struct {
103- Id uint8 // network ID used for addresses
104- Name string
105- NetworkMagic uint32
106- PublicRootAddress string
107- PublicRootPort uint
115+ Id uint8 // network ID used for addresses
116+ Name string
117+ NetworkMagic uint32
118+ BootstrapPeers []NetworkBootstrapPeer
119+ }
120+
121+ type NetworkBootstrapPeer struct {
122+ Address string
123+ Port uint
108124}
109125
110126func (n Network ) String () string {
0 commit comments