Skip to content

Commit c63c2a8

Browse files
committed
style
1 parent c9a96c0 commit c63c2a8

File tree

4 files changed

+20
-44
lines changed

4 files changed

+20
-44
lines changed

src/consensus/fork_choice.zig

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,18 +5155,20 @@ const TestDuplicateForks = struct {
51555155
});
51565156
}
51575157

5158-
// // Verify children of slot 4
5159-
// var dup_children_4 = fork_choice.getChildren(&.{
5160-
// .slot = 4,
5161-
// .hash = Hash.ZEROES,
5162-
// }).?;
5163-
5164-
// std.mem.sort(SlotAndHash, dup_children_4.mutableKeys(), {}, compareSlotHashKey);
5165-
// std.debug.assert(dup_children_4.keys()[0].equals(duplicate_leaves_descended_from_4.items[0]));
5166-
// std.debug.assert(dup_children_4.keys()[1].equals(duplicate_leaves_descended_from_4.items[1]));
5167-
5168-
var dup_children_5: std.ArrayListUnmanaged(SlotAndHash) = .empty;
5169-
defer dup_children_5.deinit(gpa);
5158+
// Verify children of slot 4
5159+
{
5160+
var dup_children_4 = fork_choice.getChildren(&.{ .slot = 4, .hash = Hash.ZEROES }).?;
5161+
var dup_iter = dup_children_4.iterator();
5162+
std.debug.assert(
5163+
dup_iter.next().?.key_ptr.equals(duplicate_leaves_descended_from_4.items[0]),
5164+
);
5165+
std.debug.assert(
5166+
dup_iter.next().?.key_ptr.equals(duplicate_leaves_descended_from_4.items[1]),
5167+
);
5168+
}
5169+
5170+
var dup_children_5 = std.ArrayList(SlotAndHash).init(test_allocator);
5171+
defer dup_children_5.deinit();
51705172

51715173
var children_5 = fork_choice.getChildren(&.{
51725174
.slot = 5,

src/ledger/shred_inserter/slot_chaining.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const SlotMeta = ledger.meta.SlotMeta;
1616
const SlotMetaWorkingSetEntry = shred_inserter.working_state.SlotMetaWorkingSetEntry;
1717
const WriteBatch = LedgerDB.WriteBatch;
1818

19-
const deinitMapRecursive = shred_inserter.working_state.deinitMapRecursive;
2019
const isNewlyCompletedSlot = shred_inserter.working_state.isNewlyCompletedSlot;
2120

2221
/// agave: handle_chaining

src/ledger/shred_inserter/working_state.zig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,14 +578,6 @@ pub const ShredWorkingStore = struct {
578578
}
579579
};
580580

581-
pub fn deinitMapRecursive(map: anytype) void {
582-
var iter = map.iterator();
583-
while (iter.next()) |entry| {
584-
entry.value_ptr.deinit();
585-
}
586-
map.deinit();
587-
}
588-
589581
/// agave: is_newly_completed_slot
590582
pub fn isNewlyCompletedSlot(slot_meta: *const SlotMeta, backup_slot_meta: *const ?SlotMeta) bool {
591583
return slot_meta.isFull() and ( //

src/utils/collections.zig

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ pub fn SortedMap(
498498
const parent_node = self.path.node_stack[h];
499499
const parent_idx = self.path.idx_stack[h];
500500
const parent_inner = self.sorted_tree.asPtr(InnerNode, parent_node);
501-
if (parent_idx > 0 and !keysEql(parent_inner.keys[parent_idx - 1], EMPTY_KEY)) {
501+
if (parent_idx > 0 and
502+
!keysEql(parent_inner.keys[parent_idx - 1], EMPTY_KEY))
503+
{
502504
node_offset = parent_inner.values[parent_idx - 1];
503505
self.path.idx_stack[h] = parent_idx - 1;
504506
// Descend to rightmost leaf
@@ -836,7 +838,9 @@ pub fn SortedMap(
836838

837839
const new_node_offset: Offset = @intCast(self.data.items.len + padding_len);
838840
self.data.items.len += @sizeOf(Node);
839-
const node: *Node = @alignCast(@ptrCast(self.data.items[padding_len..][new_node_offset..][0..@sizeOf(Node)]));
841+
const node: *Node = @alignCast(@ptrCast(
842+
self.data.items[padding_len..][new_node_offset..][0..@sizeOf(Node)],
843+
));
840844
node.* = .{ .keys = @splat(EMPTY_KEY), .values = @splat(undefined) };
841845
return new_node_offset;
842846
}
@@ -1435,7 +1439,6 @@ pub fn deinitMapAndValues(allocator: Allocator, const_map: anytype) void {
14351439

14361440
const expect = std.testing.expect;
14371441
const expectEqual = std.testing.expectEqual;
1438-
const expectEqualSlices = std.testing.expectEqualSlices;
14391442

14401443
test SortedSet {
14411444
const allocator = std.testing.allocator;
@@ -1592,26 +1595,6 @@ test "order slices" {
15921595
try expectEqual(orderSlices(u8, std.math.order, &e, &b), .lt);
15931596
}
15941597

1595-
// test "SortedMap slice range" {
1596-
// const allocator = std.testing.allocator;
1597-
1598-
// var set: SortedSet([]const u8, .{ .empty_key = "empty" }) = .empty;
1599-
// defer set.deinit(allocator);
1600-
1601-
// try set.put(allocator, &.{ 0, 0, 10 }, {});
1602-
// try set.put(allocator, &.{ 0, 0, 20 }, {});
1603-
// try set.put(allocator, &.{ 0, 0, 30 }, {});
1604-
// try set.put(allocator, &.{ 0, 0, 40 }, {});
1605-
1606-
// const range = set.rangeCustom(null, .{ .inclusive = &.{ 0, 0, 40 } });
1607-
1608-
// try std.testing.expectEqual(4, range.len);
1609-
// try std.testing.expectEqualSlices(u8, &.{ 0, 0, 10 }, range[0]);
1610-
// try std.testing.expectEqualSlices(u8, &.{ 0, 0, 20 }, range[1]);
1611-
// try std.testing.expectEqualSlices(u8, &.{ 0, 0, 30 }, range[2]);
1612-
// try std.testing.expectEqualSlices(u8, &.{ 0, 0, 40 }, range[3]);
1613-
// }
1614-
16151598
test "binarySearch slice of slices" {
16161599
const slices = [4][]const u8{
16171600
&.{ 0, 0, 10 },

0 commit comments

Comments
 (0)