@@ -18,93 +18,109 @@ import "github.com/blinklabs-io/gouroboros/ledger/common"
18
18
19
19
// Network definitions
20
20
var (
21
- NetworkTestnet = Network {
22
- Id : common .AddressNetworkTestnet ,
23
- Name : "testnet" ,
24
- NetworkMagic : 1097911063 ,
25
- }
26
21
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
+ },
32
39
}
33
40
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
+ },
39
50
}
40
51
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
+ },
46
61
}
47
62
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
+ },
53
72
}
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
60
73
)
61
74
62
75
// List of valid networks for use in lookup functions
63
76
var networks = []Network {
64
- NetworkTestnet ,
65
77
NetworkMainnet ,
66
78
NetworkPreprod ,
67
79
NetworkPreview ,
68
80
NetworkSancho ,
69
81
}
70
82
71
83
// NetworkByName returns a predefined network by name
72
- func NetworkByName (name string ) Network {
84
+ func NetworkByName (name string ) ( Network , bool ) {
73
85
for _ , network := range networks {
74
86
if network .Name == name {
75
- return network
87
+ return network , true
76
88
}
77
89
}
78
- return NetworkInvalid
90
+ return Network {}, false
79
91
}
80
92
81
93
// NetworkById returns a predefined network by ID
82
- func NetworkById (id uint8 ) Network {
94
+ func NetworkById (id uint8 ) ( Network , bool ) {
83
95
for _ , network := range networks {
84
96
if network .Id == id {
85
- return network
97
+ return network , true
86
98
}
87
99
}
88
- return NetworkInvalid
100
+ return Network {}, false
89
101
}
90
102
91
103
// NetworkByNetworkMagic returns a predefined network by network magic
92
- func NetworkByNetworkMagic (networkMagic uint32 ) Network {
104
+ func NetworkByNetworkMagic (networkMagic uint32 ) ( Network , bool ) {
93
105
for _ , network := range networks {
94
106
if network .NetworkMagic == networkMagic {
95
- return network
107
+ return network , true
96
108
}
97
109
}
98
- return NetworkInvalid
110
+ return Network {}, false
99
111
}
100
112
101
113
// Network represents a Cardano network
102
114
type 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
108
124
}
109
125
110
126
func (n Network ) String () string {
0 commit comments