@@ -127,14 +127,6 @@ pub const SlotModifiedIterator = union(enum) {
127
127
.noop = > null ,
128
128
};
129
129
}
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
- }
138
130
};
139
131
140
132
/// Interface for reading any account as it should appear during a particular slot.
@@ -268,7 +260,7 @@ pub const ThreadSafeAccountMap = struct {
268
260
else
269
261
asAccount (account );
270
262
}
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 ) {
272
264
return if (account .lamports == 0 ) null else asAccount (account );
273
265
};
274
266
}
@@ -576,6 +568,7 @@ test "insertion basic" {
576
568
const stores = [_ ]sig.accounts_db.AccountStore { simple_store , real_store };
577
569
578
570
try expectEqualDatabaseWithAncestors (
571
+ allocator ,
579
572
&.EMPTY ,
580
573
simple_state .pubkey_map .keys (),
581
574
simple_store .reader (),
@@ -596,6 +589,7 @@ test "insertion basic" {
596
589
try ancestor_set .addSlot (allocator , slot );
597
590
try putAccountIntoStores ({}, & stores , slot , pubkey , account );
598
591
try expectEqualDatabaseWithAncestors (
592
+ allocator ,
599
593
& ancestor_set ,
600
594
simple_state .pubkey_map .keys (),
601
595
simple_store .reader (),
@@ -610,6 +604,7 @@ test "insertion basic" {
610
604
const slot : Slot = i ;
611
605
try ancestor_set .subsetInto (slot , allocator , & ancestors_subset );
612
606
try expectEqualDatabaseWithAncestors (
607
+ allocator ,
613
608
& ancestors_subset ,
614
609
simple_state .pubkey_map .keys (),
615
610
simple_store .reader (),
@@ -649,6 +644,7 @@ test "insertion out of order" {
649
644
const stores = [_ ]sig.accounts_db.AccountStore { simple_store , real_store };
650
645
651
646
try expectEqualDatabaseWithAncestors (
647
+ allocator ,
652
648
&.EMPTY ,
653
649
simple_state .pubkey_map .keys (),
654
650
simple_store .reader (),
@@ -674,6 +670,7 @@ test "insertion out of order" {
674
670
try putAccountIntoStores ({}, & stores , slot , pubkey , account );
675
671
676
672
try expectEqualDatabaseWithAncestors (
673
+ allocator ,
677
674
& ancestor_set ,
678
675
simple_state .pubkey_map .keys (),
679
676
simple_store .reader (),
@@ -687,6 +684,7 @@ test "insertion out of order" {
687
684
for (ancestor_set .ancestors .keys ()) | slot | {
688
685
try ancestor_set .subsetInto (slot , allocator , & ancestors_subset );
689
686
try expectEqualDatabaseWithAncestors (
687
+ allocator ,
690
688
& ancestors_subset ,
691
689
simple_state .pubkey_map .keys (),
692
690
simple_store .reader (),
@@ -1043,11 +1041,11 @@ fn expectAccountFromStores(
1043
1041
for (stores ) | store | {
1044
1042
errdefer std .log .err ("Occurred with store impl '{s}'" , .{@tagName (store )});
1045
1043
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 {
1047
1045
try std .testing .expectEqual (maybe_expected_account , null );
1048
1046
continue ;
1049
1047
};
1050
- defer actual_account .deinit (reader . allocator () );
1048
+ defer actual_account .deinit (allocator );
1051
1049
1052
1050
const expected_account = maybe_expected_account orelse {
1053
1051
try std .testing .expectEqual (null , actual_account );
@@ -1058,6 +1056,7 @@ fn expectAccountFromStores(
1058
1056
}
1059
1057
1060
1058
fn expectEqualDatabaseWithAncestors (
1059
+ allocator : std.mem.Allocator ,
1061
1060
ancestors : * const Ancestors ,
1062
1061
pubkeys : []const Pubkey ,
1063
1062
expected : sig.accounts_db.AccountReader ,
@@ -1069,11 +1068,11 @@ fn expectEqualDatabaseWithAncestors(
1069
1068
const expected_for_slot = expected .forSlot (ancestors );
1070
1069
const actual_for_slot = actual .forSlot (ancestors );
1071
1070
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 );
1074
1073
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 );
1077
1076
1078
1077
if (expected_account_opt == null and
1079
1078
actual_account_opt == null )
@@ -1092,8 +1091,6 @@ fn expectEqualDatabaseWithAncestors(
1092
1091
try actual_account .expectEquals (expected_account );
1093
1092
}
1094
1093
1095
- const allocator = std .testing .allocator ;
1096
-
1097
1094
var expected_map : std .AutoArrayHashMapUnmanaged (Pubkey , AccountSharedData ) = .empty ;
1098
1095
defer expected_map .deinit (allocator );
1099
1096
@@ -1136,8 +1133,8 @@ fn collectModifiedSlotsIntoMap(
1136
1133
defer iter .unlock ();
1137
1134
try map .ensureTotalCapacity (allocator , iter .len ());
1138
1135
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 );
1141
1138
map .putAssumeCapacity (address , .{
1142
1139
.lamports = account .lamports ,
1143
1140
.data = try account .data .readAllAllocate (allocator ),
0 commit comments