@@ -48,7 +48,7 @@ pub async fn sync_listeners<B: BlockSource, C: Cache>(
4848 let mut most_connected_blocks = Vec :: new ( ) ;
4949 for ( old_header, chain_listener) in chain_listeners_with_old_headers. drain ( ..) {
5050 // Disconnect any stale blocks, but keep them in the cache for the next iteration.
51- let header_cache = & mut NonDiscardingCache ( header_cache) ;
51+ let header_cache = & mut ReadOnlyCache ( header_cache) ;
5252 let mut chain_notifier = ChainNotifier { header_cache } ;
5353 let difference =
5454 chain_notifier. find_difference ( new_header, & old_header, & mut chain_poller) . await ?;
@@ -80,11 +80,13 @@ pub async fn sync_listeners<B: BlockSource, C: Cache>(
8080 Ok ( new_header)
8181}
8282
83- /// A cache that won't discard any block headers. Used to prevent losing headers that are needed to
84- /// disconnect blocks common to more than one listener.
85- struct NonDiscardingCache < ' a , C : Cache > ( & ' a mut C ) ;
83+ /// A wrapper to make a cache read-only.
84+ ///
85+ /// Used to prevent losing headers that may be needed to disconnect blocks common to more than one
86+ /// listener.
87+ struct ReadOnlyCache < ' a , C : Cache > ( & ' a mut C ) ;
8688
87- impl < ' a , C : Cache > Cache for NonDiscardingCache < ' a , C > {
89+ impl < ' a , C : Cache > Cache for ReadOnlyCache < ' a , C > {
8890 fn look_up ( & self , block_hash : & BlockHash ) -> Option < & ValidatedBlockHeader > {
8991 self . 0 . look_up ( block_hash)
9092 }
0 commit comments