@@ -82,7 +82,7 @@ impl LogConfig {
8282/// Ephemeral state for pooling entries to the CT log.
8383///
8484/// The pool is written to by `add_leaf_to_pool`, and by the sequencer
85- /// when rotating ` pending` and `in_sequencing` .
85+ /// when rotating pending and in-sequencing entries .
8686///
8787/// As long as the above-mentioned blocks run synchronously (no 'await's), Durable Objects'
8888/// single-threaded execution guarantees that `add_leaf_to_pool` will never add to a pool that
@@ -92,26 +92,26 @@ impl LogConfig {
9292#[ derive( Debug ) ]
9393pub ( crate ) struct PoolState < P : PendingLogEntryTrait > {
9494 // How many times the oldest entry has been held back from sequencing.
95- holds : usize ,
95+ oldest_pending_entry_holds : usize ,
9696
9797 // Entries that are ready to be sequenced, along with the Sender used to
9898 // send metadata to receivers once the corresponding entry is sequenced.
9999 pending_entries : Vec < ( P , Sender < SequenceMetadata > ) > ,
100100
101101 // Deduplication cache for entries currently pending sequencing.
102- pending : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
102+ pending_dedup : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
103103
104104 // Deduplication cache for entries currently being sequenced.
105- in_sequencing : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
105+ in_sequencing_dedup : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
106106}
107107
108108impl < P : PendingLogEntryTrait > Default for PoolState < P > {
109109 fn default ( ) -> Self {
110110 PoolState {
111- holds : 0 ,
111+ oldest_pending_entry_holds : 0 ,
112112 pending_entries : Default :: default ( ) ,
113- pending : Default :: default ( ) ,
114- in_sequencing : Default :: default ( ) ,
113+ pending_dedup : Default :: default ( ) ,
114+ in_sequencing_dedup : Default :: default ( ) ,
115115 }
116116 }
117117}
@@ -120,17 +120,19 @@ impl<E: PendingLogEntryTrait> PoolState<E> {
120120 // Check if the key is already in the pool. If so, return a Receiver from
121121 // which to read the entry metadata when it is sequenced.
122122 fn check ( & self , key : & LookupKey ) -> Option < AddLeafResult > {
123- if let Some ( rx) = self . in_sequencing . get ( key) {
123+ if let Some ( rx) = self . in_sequencing_dedup . get ( key) {
124124 // Entry is being sequenced.
125125 Some ( AddLeafResult :: Pending {
126126 rx : rx. clone ( ) ,
127127 source : PendingSource :: InSequencing ,
128128 } )
129129 } else {
130- self . pending . get ( key) . map ( |rx| AddLeafResult :: Pending {
131- rx : rx. clone ( ) ,
132- source : PendingSource :: Pool ,
133- } )
130+ self . pending_dedup
131+ . get ( key)
132+ . map ( |rx| AddLeafResult :: Pending {
133+ rx : rx. clone ( ) ,
134+ source : PendingSource :: Pool ,
135+ } )
134136 }
135137 }
136138 // Add a new entry to the pool.
@@ -140,7 +142,7 @@ impl<E: PendingLogEntryTrait> PoolState<E> {
140142 }
141143 let ( tx, rx) = channel ( ( 0 , 0 ) ) ;
142144 self . pending_entries . push ( ( entry, tx) ) ;
143- self . pending . insert ( key, rx. clone ( ) ) ;
145+ self . pending_dedup . insert ( key, rx. clone ( ) ) ;
144146
145147 AddLeafResult :: Pending {
146148 rx,
@@ -166,20 +168,20 @@ impl<E: PendingLogEntryTrait> PoolState<E> {
166168 // We're going to publish at least one full tile which will contain
167169 // any leftover entries from the previous sequencing. Reset the
168170 // count since the new leftover entries have not yet been held back.
169- self . holds = 0 ;
171+ self . oldest_pending_entry_holds = 0 ;
170172 }
171173 // Flush all of the leftover entries if the oldest is before the cutoff.
172- let flush_oldest = self . holds >= max_pending_entry_holds;
174+ let flush_oldest = self . oldest_pending_entry_holds >= max_pending_entry_holds;
173175
174176 if leftover == 0 || flush_oldest {
175177 // Sequence everything. Either there are no leftovers or they have
176178 // already been held back the maximum number of times.
177- self . holds = 0 ;
178- self . in_sequencing = std:: mem:: take ( & mut self . pending ) ;
179+ self . oldest_pending_entry_holds = 0 ;
180+ self . in_sequencing_dedup = std:: mem:: take ( & mut self . pending_dedup ) ;
179181 std:: mem:: take ( & mut self . pending_entries )
180182 } else {
181183 // Hold back the leftovers to avoid creating a partial tile.
182- self . holds += 1 ;
184+ self . oldest_pending_entry_holds += 1 ;
183185
184186 if publishing_full_tile {
185187 // Return the pending entries to be published in full tiles and
@@ -190,10 +192,13 @@ impl<E: PendingLogEntryTrait> PoolState<E> {
190192 . iter ( )
191193 . filter_map ( |( entry, _) | {
192194 let lookup_key = entry. lookup_key ( ) ;
193- self . pending . remove ( & lookup_key) . map ( |rx| ( lookup_key, rx) )
195+ self . pending_dedup
196+ . remove ( & lookup_key)
197+ . map ( |rx| ( lookup_key, rx) )
194198 } )
195199 . collect :: < HashMap < _ , _ > > ( ) ;
196- self . in_sequencing = std:: mem:: replace ( & mut self . pending , leftover_pending) ;
200+ self . in_sequencing_dedup =
201+ std:: mem:: replace ( & mut self . pending_dedup , leftover_pending) ;
197202 std:: mem:: replace ( & mut self . pending_entries , leftover_entries)
198203 } else {
199204 // We didn't fill up a full tile, so nothing to return.
@@ -204,7 +209,7 @@ impl<E: PendingLogEntryTrait> PoolState<E> {
204209 // Reset the map of in-sequencing entries. This should be called after
205210 // sequencing completes.
206211 fn reset ( & mut self ) {
207- self . in_sequencing . clear ( ) ;
212+ self . in_sequencing_dedup . clear ( ) ;
208213 }
209214}
210215
0 commit comments