Skip to content

Commit 1c81af9

Browse files
committed
post-rebase fixups
1 parent 874faa0 commit 1c81af9

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/accountsdb/account_store.zig

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ pub const SlotModifiedIterator = union(enum) {
127127
.noop => null,
128128
};
129129
}
130-
131-
pub fn allocator(self: SlotModifiedIterator) std.mem.Allocator {
132-
return switch (self) {
133-
.accounts_db => |state| state.db.allocator,
134-
.thread_safe_map => |state| state.allocator,
135-
.noop => sig.utils.allocators.failing.allocator(.{}),
136-
};
137-
}
138130
};
139131

140132
/// Interface for reading any account as it should appear during a particular slot.
@@ -268,7 +260,7 @@ pub const ThreadSafeAccountMap = struct {
268260
else
269261
asAccount(account);
270262
}
271-
if (self.last_rooted_slot) |last_rooted_slot| if (slot <= last_rooted_slot) {
263+
if (self.largest_rooted_slot) |largest_rooted_slot| if (slot <= largest_rooted_slot) {
272264
return if (account.lamports == 0) null else asAccount(account);
273265
};
274266
}
@@ -576,6 +568,7 @@ test "insertion basic" {
576568
const stores = [_]sig.accounts_db.AccountStore{ simple_store, real_store };
577569

578570
try expectEqualDatabaseWithAncestors(
571+
allocator,
579572
&.EMPTY,
580573
simple_state.pubkey_map.keys(),
581574
simple_store.reader(),
@@ -596,6 +589,7 @@ test "insertion basic" {
596589
try ancestor_set.addSlot(allocator, slot);
597590
try putAccountIntoStores({}, &stores, slot, pubkey, account);
598591
try expectEqualDatabaseWithAncestors(
592+
allocator,
599593
&ancestor_set,
600594
simple_state.pubkey_map.keys(),
601595
simple_store.reader(),
@@ -610,6 +604,7 @@ test "insertion basic" {
610604
const slot: Slot = i;
611605
try ancestor_set.subsetInto(slot, allocator, &ancestors_subset);
612606
try expectEqualDatabaseWithAncestors(
607+
allocator,
613608
&ancestors_subset,
614609
simple_state.pubkey_map.keys(),
615610
simple_store.reader(),
@@ -649,6 +644,7 @@ test "insertion out of order" {
649644
const stores = [_]sig.accounts_db.AccountStore{ simple_store, real_store };
650645

651646
try expectEqualDatabaseWithAncestors(
647+
allocator,
652648
&.EMPTY,
653649
simple_state.pubkey_map.keys(),
654650
simple_store.reader(),
@@ -674,6 +670,7 @@ test "insertion out of order" {
674670
try putAccountIntoStores({}, &stores, slot, pubkey, account);
675671

676672
try expectEqualDatabaseWithAncestors(
673+
allocator,
677674
&ancestor_set,
678675
simple_state.pubkey_map.keys(),
679676
simple_store.reader(),
@@ -687,6 +684,7 @@ test "insertion out of order" {
687684
for (ancestor_set.ancestors.keys()) |slot| {
688685
try ancestor_set.subsetInto(slot, allocator, &ancestors_subset);
689686
try expectEqualDatabaseWithAncestors(
687+
allocator,
690688
&ancestors_subset,
691689
simple_state.pubkey_map.keys(),
692690
simple_store.reader(),
@@ -1043,11 +1041,11 @@ fn expectAccountFromStores(
10431041
for (stores) |store| {
10441042
errdefer std.log.err("Occurred with store impl '{s}'", .{@tagName(store)});
10451043
const reader = store.reader();
1046-
const actual_account = try reader.forSlot(ancestors).get(address) orelse {
1044+
const actual_account = try reader.forSlot(ancestors).get(allocator, address) orelse {
10471045
try std.testing.expectEqual(maybe_expected_account, null);
10481046
continue;
10491047
};
1050-
defer actual_account.deinit(reader.allocator());
1048+
defer actual_account.deinit(allocator);
10511049

10521050
const expected_account = maybe_expected_account orelse {
10531051
try std.testing.expectEqual(null, actual_account);
@@ -1058,6 +1056,7 @@ fn expectAccountFromStores(
10581056
}
10591057

10601058
fn expectEqualDatabaseWithAncestors(
1059+
allocator: std.mem.Allocator,
10611060
ancestors: *const Ancestors,
10621061
pubkeys: []const Pubkey,
10631062
expected: sig.accounts_db.AccountReader,
@@ -1069,11 +1068,11 @@ fn expectEqualDatabaseWithAncestors(
10691068
const expected_for_slot = expected.forSlot(ancestors);
10701069
const actual_for_slot = actual.forSlot(ancestors);
10711070
for (pubkeys) |pubkey| {
1072-
const expected_account_opt = try expected_for_slot.get(pubkey);
1073-
defer if (expected_account_opt) |acc| acc.deinit(expected_for_slot.allocator());
1071+
const expected_account_opt = try expected_for_slot.get(allocator, pubkey);
1072+
defer if (expected_account_opt) |acc| acc.deinit(allocator);
10741073

1075-
const actual_account_opt = try actual_for_slot.get(pubkey);
1076-
defer if (actual_account_opt) |acc| acc.deinit(actual_for_slot.allocator());
1074+
const actual_account_opt = try actual_for_slot.get(allocator, pubkey);
1075+
defer if (actual_account_opt) |acc| acc.deinit(allocator);
10771076

10781077
if (expected_account_opt == null and
10791078
actual_account_opt == null)
@@ -1092,8 +1091,6 @@ fn expectEqualDatabaseWithAncestors(
10921091
try actual_account.expectEquals(expected_account);
10931092
}
10941093

1095-
const allocator = std.testing.allocator;
1096-
10971094
var expected_map: std.AutoArrayHashMapUnmanaged(Pubkey, AccountSharedData) = .empty;
10981095
defer expected_map.deinit(allocator);
10991096

@@ -1136,8 +1133,8 @@ fn collectModifiedSlotsIntoMap(
11361133
defer iter.unlock();
11371134
try map.ensureTotalCapacity(allocator, iter.len());
11381135
while (true) {
1139-
const address, const account = try iter.next() orelse break;
1140-
defer account.deinit(iter.allocator());
1136+
const address, const account = try iter.next(allocator) orelse break;
1137+
defer account.deinit(allocator);
11411138
map.putAssumeCapacity(address, .{
11421139
.lamports = account.lamports,
11431140
.data = try account.data.readAllAllocate(allocator),

0 commit comments

Comments
 (0)