@@ -67,7 +67,7 @@ pub(crate) struct LogConfig {
6767/// Ephemeral state for pooling entries to the CT log.
6868///
6969/// The pool is written to by `add_leaf_to_pool`, and by the sequencer
70- /// when rotating ` pending` and `in_sequencing` .
70+ /// when rotating pending and in-sequencing entries .
7171///
7272/// As long as the above-mentioned blocks run synchronously (no 'await's), Durable Objects'
7373/// single-threaded execution guarantees that `add_leaf_to_pool` will never add to a pool that
@@ -77,34 +77,36 @@ pub(crate) struct LogConfig {
7777#[ derive( Default , Debug ) ]
7878pub ( crate ) struct PoolState {
7979 // How many times the oldest entry has been held back from sequencing.
80- holds : usize ,
80+ oldest_pending_entry_holds : usize ,
8181
8282 // Entries that are ready to be sequenced, along with the Sender used to
8383 // send metadata to receivers once the corresponding entry is sequenced.
8484 pending_entries : Vec < ( PendingLogEntry , Sender < SequenceMetadata > ) > ,
8585
8686 // Deduplication cache for entries currently pending sequencing.
87- pending : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
87+ pending_dedup : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
8888
8989 // Deduplication cache for entries currently being sequenced.
90- in_sequencing : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
90+ in_sequencing_dedup : HashMap < LookupKey , Receiver < SequenceMetadata > > ,
9191}
9292
9393impl PoolState {
9494 // Check if the key is already in the pool. If so, return a Receiver from
9595 // which to read the entry metadata when it is sequenced.
9696 fn check ( & self , key : & LookupKey ) -> Option < AddLeafResult > {
97- if let Some ( rx) = self . in_sequencing . get ( key) {
97+ if let Some ( rx) = self . in_sequencing_dedup . get ( key) {
9898 // Entry is being sequenced.
9999 Some ( AddLeafResult :: Pending {
100100 rx : rx. clone ( ) ,
101101 source : PendingSource :: InSequencing ,
102102 } )
103103 } else {
104- self . pending . get ( key) . map ( |rx| AddLeafResult :: Pending {
105- rx : rx. clone ( ) ,
106- source : PendingSource :: Pool ,
107- } )
104+ self . pending_dedup
105+ . get ( key)
106+ . map ( |rx| AddLeafResult :: Pending {
107+ rx : rx. clone ( ) ,
108+ source : PendingSource :: Pool ,
109+ } )
108110 }
109111 }
110112 // Add a new entry to the pool.
@@ -114,7 +116,7 @@ impl PoolState {
114116 }
115117 let ( tx, rx) = channel ( ( 0 , 0 ) ) ;
116118 self . pending_entries . push ( ( entry, tx) ) ;
117- self . pending . insert ( key, rx. clone ( ) ) ;
119+ self . pending_dedup . insert ( key, rx. clone ( ) ) ;
118120
119121 AddLeafResult :: Pending {
120122 rx,
@@ -140,20 +142,20 @@ impl PoolState {
140142 // We're going to publish at least one full tile which will contain
141143 // any leftover entries from the previous sequencing. Reset the
142144 // count since the new leftover entries have not yet been held back.
143- self . holds = 0 ;
145+ self . oldest_pending_entry_holds = 0 ;
144146 }
145147 // Flush all of the leftover entries if the oldest is before the cutoff.
146- let flush_oldest = self . holds >= max_pending_entry_holds;
148+ let flush_oldest = self . oldest_pending_entry_holds >= max_pending_entry_holds;
147149
148150 if leftover == 0 || flush_oldest {
149151 // Sequence everything. Either there are no leftovers or they have
150152 // already been held back the maximum number of times.
151- self . holds = 0 ;
152- self . in_sequencing = std:: mem:: take ( & mut self . pending ) ;
153+ self . oldest_pending_entry_holds = 0 ;
154+ self . in_sequencing_dedup = std:: mem:: take ( & mut self . pending_dedup ) ;
153155 std:: mem:: take ( & mut self . pending_entries )
154156 } else {
155157 // Hold back the leftovers to avoid creating a partial tile.
156- self . holds += 1 ;
158+ self . oldest_pending_entry_holds += 1 ;
157159
158160 if publishing_full_tile {
159161 // Return the pending entries to be published in full tiles and
@@ -164,10 +166,13 @@ impl PoolState {
164166 . iter ( )
165167 . filter_map ( |( entry, _) | {
166168 let lookup_key = entry. lookup_key ( ) ;
167- self . pending . remove ( & lookup_key) . map ( |rx| ( lookup_key, rx) )
169+ self . pending_dedup
170+ . remove ( & lookup_key)
171+ . map ( |rx| ( lookup_key, rx) )
168172 } )
169173 . collect :: < HashMap < _ , _ > > ( ) ;
170- self . in_sequencing = std:: mem:: replace ( & mut self . pending , leftover_pending) ;
174+ self . in_sequencing_dedup =
175+ std:: mem:: replace ( & mut self . pending_dedup , leftover_pending) ;
171176 std:: mem:: replace ( & mut self . pending_entries , leftover_entries)
172177 } else {
173178 // We didn't fill up a full tile, so nothing to return.
@@ -178,7 +183,7 @@ impl PoolState {
178183 // Reset the map of in-sequencing entries. This should be called after
179184 // sequencing completes.
180185 fn reset ( & mut self ) {
181- self . in_sequencing . clear ( ) ;
186+ self . in_sequencing_dedup . clear ( ) ;
182187 }
183188}
184189
0 commit comments