@@ -250,17 +250,50 @@ pub const Inflation = struct {
250250 }
251251};
252252
253- /// Analogous to [ClusterType](https://github.com/anza-xyz/agave /blob/cadba689cb44db93e9c625770cafd2fc0ae89e33/sdk /src/genesis_config .rs#L46 )
253+ /// Analogous to [ClusterType](https://github.com/anza-xyz/solana-sdk /blob/a467058aabc453c7d749a4993c56df293d1d75c3/cluster-type /src/lib .rs#L19 )
254254/// Explicit numbers are added to ensure we don't mess up the order of the fields and break bincode reading.
255- pub const ClusterType = union (enum (u8 )) {
256- Testnet = 0 ,
257- MainnetBeta = 1 ,
258- Devnet = 2 ,
259- Development = 3 ,
260- LocalHost ,
261- Custom : struct {
262- url : []const u8 ,
263- },
255+ pub const ClusterType = enum (u8 ) {
256+ testnet = 0 ,
257+ mainnet = 1 ,
258+ devnet = 2 ,
259+ development = 3 ,
260+
261+ /// Returns entrypoints for public clusters, null for development.
262+ /// For development, the caller must provide entrypoints manually.
263+ pub fn getEntrypoints (self : ClusterType ) []const []const u8 {
264+ return switch (self ) {
265+ .mainnet = > &.{
266+ "entrypoint.mainnet-beta.solana.com:8001" ,
267+ "entrypoint2.mainnet-beta.solana.com:8001" ,
268+ "entrypoint3.mainnet-beta.solana.com:8001" ,
269+ "entrypoint4.mainnet-beta.solana.com:8001" ,
270+ "entrypoint5.mainnet-beta.solana.com:8001" ,
271+ },
272+ .testnet = > &.{
273+ "entrypoint.testnet.solana.com:8001" ,
274+ "entrypoint2.testnet.solana.com:8001" ,
275+ "entrypoint3.testnet.solana.com:8001" ,
276+ },
277+ .devnet = > &.{
278+ "entrypoint.devnet.solana.com:8001" ,
279+ "entrypoint2.devnet.solana.com:8001" ,
280+ "entrypoint3.devnet.solana.com:8001" ,
281+ "entrypoint4.devnet.solana.com:8001" ,
282+ "entrypoint5.devnet.solana.com:8001" ,
283+ },
284+ .development = > @panic ("TODO: should development require custom entrypoints?" ),
285+ };
286+ }
287+
288+ /// Returns the RPC URL for this cluster.
289+ pub fn getRpcUrl (self : ClusterType ) []const u8 {
290+ return switch (self ) {
291+ .mainnet = > "https://api.mainnet-beta.solana.com" ,
292+ .testnet = > "https://api.testnet.solana.com" ,
293+ .devnet = > "https://api.devnet.solana.com" ,
294+ .development = > @panic ("TODO: should development require custom rpc urls?" ),
295+ };
296+ }
264297};
265298
266299/// Analogous to [GenesisConfig](https://github.com/anza-xyz/agave/blob/cadba689cb44db93e9c625770cafd2fc0ae89e33/sdk/src/genesis_config.rs#L93)
@@ -312,7 +345,7 @@ pub const GenesisConfig = struct {
312345 .fee_rate_governor = .DEFAULT ,
313346 .rent = .INIT ,
314347 .epoch_schedule = .INIT ,
315- .cluster_type = .Development ,
348+ .cluster_type = .development ,
316349 };
317350 }
318351
@@ -352,7 +385,7 @@ test "genesis_config deserialize development config" {
352385 const config = try GenesisConfig .init (allocator , genesis_path );
353386 defer config .deinit (allocator );
354387
355- try std .testing .expectEqual (ClusterType .Development , config .cluster_type );
388+ try std .testing .expectEqual (ClusterType .development , config .cluster_type );
356389}
357390
358391test "genesis_config deserialize testnet config" {
@@ -362,7 +395,7 @@ test "genesis_config deserialize testnet config" {
362395 const config = try GenesisConfig .init (allocator , genesis_path );
363396 defer config .deinit (allocator );
364397
365- try std .testing .expectEqual (ClusterType .Testnet , config .cluster_type );
398+ try std .testing .expectEqual (ClusterType .testnet , config .cluster_type );
366399}
367400
368401test "genesis_config deserialize devnet config" {
@@ -372,7 +405,7 @@ test "genesis_config deserialize devnet config" {
372405 const config = try GenesisConfig .init (allocator , genesis_path );
373406 defer config .deinit (allocator );
374407
375- try std .testing .expectEqual (ClusterType .Devnet , config .cluster_type );
408+ try std .testing .expectEqual (ClusterType .devnet , config .cluster_type );
376409}
377410
378411test "genesis_config deserialize mainnet config" {
@@ -382,7 +415,7 @@ test "genesis_config deserialize mainnet config" {
382415 const config = try GenesisConfig .init (allocator , genesis_path );
383416 defer config .deinit (allocator );
384417
385- try std .testing .expectEqual (ClusterType .MainnetBeta , config .cluster_type );
418+ try std .testing .expectEqual (ClusterType .mainnet , config .cluster_type );
386419}
387420
388421test "inflation" {
0 commit comments