-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: add support for dynamic cluster discovery.
- Loading branch information
1 parent
e61f9a3
commit 0252cc3
Showing
10 changed files
with
115 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "fd_genesis_cluster.h" | ||
|
||
FD_FN_PURE ulong | ||
fd_genesis_cluster_identify( char const * expected_genesis_hash ) { | ||
char const * DEVNET_GENESIS_HASH = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG"; | ||
char const * TESTNET_GENESIS_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY"; | ||
char const * MAINNET_BETA_GENESIS_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"; | ||
char const * PYTHTEST_GENESIS_HASH = "EkCkB7RWVrgkcpariRpd3pjf7GwiCMZaMHKUpB5Na1Ve"; | ||
char const * PYTHNET_GENESIS_HASH = "GLKkBUr6r72nBtGrtBPJLRqtsh8wXZanX4xfnqKnWwKq"; | ||
|
||
ulong cluster = FD_CLUSTER_UNKNOWN; | ||
if( FD_LIKELY( expected_genesis_hash ) ) { | ||
if( FD_UNLIKELY( !strcmp( expected_genesis_hash, DEVNET_GENESIS_HASH ) ) ) cluster = FD_CLUSTER_DEVNET; | ||
else if( FD_UNLIKELY( !strcmp( expected_genesis_hash, TESTNET_GENESIS_HASH ) ) ) cluster = FD_CLUSTER_TESTNET; | ||
else if( FD_UNLIKELY( !strcmp( expected_genesis_hash, MAINNET_BETA_GENESIS_HASH ) ) ) cluster = FD_CLUSTER_MAINNET_BETA; | ||
else if( FD_UNLIKELY( !strcmp( expected_genesis_hash, PYTHTEST_GENESIS_HASH ) ) ) cluster = FD_CLUSTER_PYTHTEST; | ||
else if( FD_UNLIKELY( !strcmp( expected_genesis_hash, PYTHNET_GENESIS_HASH ) ) ) cluster = FD_CLUSTER_PYTHNET; | ||
} | ||
|
||
return cluster; | ||
} | ||
|
||
FD_FN_CONST char const * | ||
fd_genesis_cluster_name( ulong cluster ) { | ||
switch( cluster ) { | ||
case FD_CLUSTER_UNKNOWN: return "unknown"; | ||
case FD_CLUSTER_PYTHTEST: return "pythtest"; | ||
case FD_CLUSTER_TESTNET: return "testnet"; | ||
case FD_CLUSTER_DEVNET: return "devnet"; | ||
case FD_CLUSTER_PYTHNET: return "pythnet"; | ||
case FD_CLUSTER_MAINNET_BETA: return "mainnet-beta"; | ||
default: return "unknown"; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef HEADER_fd_src_flamenco_genesis_fd_genesis_cluster_h | ||
#define HEADER_fd_src_flamenco_genesis_fd_genesis_cluster_h | ||
|
||
#include "../types/fd_types.h" | ||
|
||
#define FD_CLUSTER_UNKNOWN (0UL) | ||
#define FD_CLUSTER_PYTHTEST (1UL) | ||
#define FD_CLUSTER_TESTNET (2UL) | ||
#define FD_CLUSTER_DEVNET (3UL) | ||
#define FD_CLUSTER_PYTHNET (4UL) | ||
#define FD_CLUSTER_MAINNET_BETA (5UL) | ||
|
||
/* Convert a base58 encoded hash to a FD_CLUSTER_* macro. | ||
genesis_hash should point to a non-NULL cstr. It expects a | ||
base58 encoded hash, which will be compared against known hash | ||
values for public clusters. If a match isn't found, this function | ||
returns FD_CLUSTER_UNKNOWN */ | ||
|
||
FD_FN_PURE ulong | ||
fd_genesis_cluster_identify( char const * genesis_hash ); | ||
|
||
/* Convert a FD_CLUSTER_* macro to its corresponding cstr. | ||
This function returns the human-readable name associated with cluster | ||
as a cstr with a static lifetime. For example, FD_CLUSTER_TESTNET | ||
resolves to "testnet". If cluster is not a FD_CLUSTER_* macro, | ||
this function returns "unknown" */ | ||
|
||
FD_FN_CONST char const * | ||
fd_genesis_cluster_name( ulong cluster ); | ||
|
||
#endif /* HEADER_fd_src_flamenco_genesis_fd_genesis_cluster_h */ |