Skip to content

Commit

Permalink
feat(cmd): add shred version option
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNineteen committed Jan 16, 2025
1 parent a0a4b72 commit cb456bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/cmd/cmd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ pub fn run() !void {
// _ = gossip_value_gpa.deinit(); // Commented out for no leeks
}

var shred_version_option = cli.Option{
.long_name = "shred-version",
.help = "The shred version for the network",
.value_ref = cli.mkRef(&config.current.shred_version),
.required = false,
.value_name = "Shred Version",
};

var gossip_host_option = cli.Option{
.long_name = "gossip-host",
.help =
Expand Down Expand Up @@ -401,6 +409,7 @@ pub fn run() !void {
&gossip_spy_node_option,
&gossip_dump_option,
&network_option,
&shred_version_option,
},
.target = .{
.action = .{
Expand All @@ -418,6 +427,7 @@ pub fn run() !void {
,
},
.options = &.{
&shred_version_option,
// gossip
&gossip_host_option,
&gossip_port_option,
Expand Down Expand Up @@ -476,6 +486,7 @@ pub fn run() !void {
\\ for testnet or another `-u` for mainnet/devnet.
},
.options = &.{
&shred_version_option,
// gossip
&gossip_host_option,
&gossip_port_option,
Expand Down Expand Up @@ -512,6 +523,7 @@ pub fn run() !void {
,
},
.options = &.{
&shred_version_option,
// where to download the snapshot
&snapshot_dir_option,
// download options
Expand Down Expand Up @@ -609,6 +621,7 @@ pub fn run() !void {
,
},
.options = &.{
&shred_version_option,
// gossip
&gossip_host_option,
&gossip_port_option,
Expand Down Expand Up @@ -648,6 +661,7 @@ pub fn run() !void {
,
},
.options = &.{
&shred_version_option,
// gossip
&network_option,
&gossip_host_option,
Expand Down Expand Up @@ -1249,7 +1263,12 @@ const AppBase = struct {
allocator,
entrypoints,
);
const my_shred_version = echo_data.shred_version orelse 0;

// zig fmt: off
const my_shred_version = config.current.shred_version
orelse echo_data.shred_version
orelse 0;
// zig fmt: on

const config_host = config.current.gossip.getHost() catch null;
const my_ip = config_host orelse echo_data.ip orelse IpAddr.newIpv4(127, 0, 0, 1);
Expand Down
1 change: 1 addition & 0 deletions src/cmd/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub const Config = struct {
// general config
log_level: LogLevel = .debug,
metrics_port: u16 = 12345,
shred_version: ?u16 = null,

pub fn genesisFilePath(self: Config) error{UnknownCluster}!?[]const u8 {
return if (self.genesis_file_path) |provided_path|
Expand Down

0 comments on commit cb456bc

Please sign in to comment.