Skip to content

Commit

Permalink
refactor(shred_collector): consolidate config
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed May 31, 2024
1 parent 61eb15a commit 5df9128
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
38 changes: 19 additions & 19 deletions src/cmd/cmd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ var gossip_port_option = cli.Option{
var repair_port_option = cli.Option{
.long_name = "repair-port",
.help = "The port to run tvu repair listener - default: 8002",
.value_ref = cli.mkRef(&config.current.tvu.repair_port),
.value_ref = cli.mkRef(&config.current.shred_collector.repair_port),
.required = false,
.value_name = "Repair Port",
};

var tvu_port_option = cli.Option{
.long_name = "tvu-port",
.help = "The port to run turbine listener - default: 8003",
.value_ref = cli.mkRef(&config.current.tvu.tvu_port),
.value_ref = cli.mkRef(&config.current.shred_collector.tvu_port),
.required = false,
.value_name = "TVU Port",
};

var test_repair_option = cli.Option{
.long_name = "test-repair-for-slot",
.help = "Set a slot here to repeatedly send repair requests for shreds from this slot. This is only intended for use during short-lived tests of the repair service. Do not set this during normal usage.",
.value_ref = cli.mkRef(&config.current.tvu.test_repair_slot),
.value_ref = cli.mkRef(&config.current.shred_collector.start_slot),
.required = false,
.value_name = "slot number",
};
Expand Down Expand Up @@ -399,8 +399,8 @@ fn validator() !void {
defer entrypoints.deinit();
const ip_echo_data = try getMyDataFromIpEcho(logger, entrypoints.items);

const repair_port: u16 = config.current.tvu.repair_port;
const tvu_port: u16 = config.current.tvu.repair_port;
const repair_port: u16 = config.current.shred_collector.repair_port;
const tvu_port: u16 = config.current.shred_collector.repair_port;

// gossip
var gossip_service = try initGossip(
Expand All @@ -419,20 +419,20 @@ fn validator() !void {
const gossip_handle = try std.Thread.spawn(.{}, runGossipWithConfigValues, .{&gossip_service});

// shred collector
var shred_collector = try sig.shred_collector.start(.{
.start_slot = if (config.current.tvu.test_repair_slot) |n| @intCast(n) else null,
.repair_port = repair_port,
.tvu_port = tvu_port,
}, .{
.allocator = gpa_allocator,
.logger = logger,
.random = rand.random(),
.my_keypair = &my_keypair,
}, .{
.exit = &exit,
.gossip_table_rw = &gossip_service.gossip_table_rw,
.my_shred_version = &gossip_service.my_shred_version,
});
var shred_collector = try sig.shred_collector.start(
config.current.shred_collector,
.{
.allocator = gpa_allocator,
.logger = logger,
.random = rand.random(),
.my_keypair = &my_keypair,
},
.{
.exit = &exit,
.gossip_table_rw = &gossip_service.gossip_table_rw,
.my_shred_version = &gossip_service.my_shred_version,
},
);
defer shred_collector.deinit();

// accounts db
Expand Down
11 changes: 6 additions & 5 deletions src/cmd/config.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const ACCOUNT_INDEX_BINS = @import("../accountsdb/db.zig").ACCOUNT_INDEX_BINS;
const ShredCollectorConfig = @import("../shred_collector/service.zig").ShredCollectorConfig;

pub const Config = struct {
identity: IdentityConfig = .{},
gossip: GossipConfig = .{},
tvu: TvuConfig = .{},
shred_collector: ShredCollectorConfig = shred_collector_defaults,
accounts_db: AccountsDbConfig = .{},
// general config
log_level: []const u8 = "debug",
Expand All @@ -24,10 +25,10 @@ const GossipConfig = struct {
trusted_validators: [][]const u8 = &.{},
};

const TvuConfig = struct {
tvu_port: u16 = 8002,
repair_port: u16 = 8003,
test_repair_slot: ?u64 = null,
const shred_collector_defaults = ShredCollectorConfig{
.tvu_port = 8002,
.repair_port = 8003,
.start_slot = null,
};

const AccountsDbConfig = struct {
Expand Down

0 comments on commit 5df9128

Please sign in to comment.