@@ -48,7 +48,7 @@ pub async fn sync_listeners<B: BlockSource, C: Cache>(
48
48
let mut most_connected_blocks = Vec :: new ( ) ;
49
49
for ( old_header, chain_listener) in chain_listeners_with_old_headers. drain ( ..) {
50
50
// 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) ;
52
52
let mut chain_notifier = ChainNotifier { header_cache } ;
53
53
let difference =
54
54
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>(
80
80
Ok ( new_header)
81
81
}
82
82
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 ) ;
86
88
87
- impl < ' a , C : Cache > Cache for NonDiscardingCache < ' a , C > {
89
+ impl < ' a , C : Cache > Cache for ReadOnlyCache < ' a , C > {
88
90
fn look_up ( & self , block_hash : & BlockHash ) -> Option < & ValidatedBlockHeader > {
89
91
self . 0 . look_up ( block_hash)
90
92
}
0 commit comments