Skip to content

Commit

Permalink
Style fixes & refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
InKryption committed Jun 3, 2024
1 parent 570ee93 commit 570bf3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/gossip/service.zig
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,14 @@ pub const GossipService = struct {
defer self.allocator.free(tasks);

// pre-allocate all the tasks
for (tasks) |*task| task.entry = .{
.allocator = task_allocator,
.verified_incoming_channel = self.verified_incoming_channel,
.packet_batch = undefined,
.logger = self.logger,
};
for (tasks) |*task| {
task.entry = .{
.allocator = task_allocator,
.verified_incoming_channel = self.verified_incoming_channel,
.packet_batch = undefined,
.logger = self.logger,
};
}

while (!self.exit.load(.unordered)) {
const maybe_packet_batches = try self.packet_incoming_channel.try_drain();
Expand Down
7 changes: 2 additions & 5 deletions src/net/socket_utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ pub fn readSocket(

while (!exit.load(.unordered)) {
// init a new batch
// var count: usize = 0;
// const capacity = PACKETS_PER_BATCH;
var packet_batch = try std.ArrayList(Packet).initCapacity(
allocator,
PACKETS_PER_BATCH,
Expand Down Expand Up @@ -72,12 +70,11 @@ pub fn sendSocket(

while (!exit.load(.unordered)) {
const maybe_packet_batches = try outgoing_channel.try_drain();
if (maybe_packet_batches == null) {
const packet_batches = maybe_packet_batches orelse {
// sleep for 1ms
// std.time.sleep(std.time.ns_per_ms * 1);
continue;
}
const packet_batches = maybe_packet_batches.?;
};
defer {
for (packet_batches) |*packet_batch| {
packet_batch.deinit();
Expand Down

0 comments on commit 570bf3e

Please sign in to comment.