@@ -155,13 +155,12 @@ impl<B: BlockT, H: Hasher> Cache<B, H> {
155
155
156
156
/// Synchronize the shared cache with the best block state.
157
157
/// This function updates the shared cache by removing entries
158
- /// that are invalidated by chain reorganization. It should be
159
- /// be called when chain reorg happens without importing a new block.
158
+ /// that are invalidated by chain reorganization. It should be called
159
+ /// externally when chain reorg happens without importing a new block.
160
160
pub fn sync ( & mut self , enacted : & [ B :: Hash ] , retracted : & [ B :: Hash ] ) {
161
161
trace ! ( "Syncing shared cache, enacted = {:?}, retracted = {:?}" , enacted, retracted) ;
162
162
163
163
// Purge changes from re-enacted and retracted blocks.
164
- // Filter out commiting block if any.
165
164
let mut clear = false ;
166
165
for block in enacted {
167
166
clear = clear || {
@@ -313,6 +312,7 @@ impl<H: Hasher, B: BlockT> CacheChanges<H, B> {
313
312
let is_best = is_best ( ) ;
314
313
trace ! ( "Syncing cache, id = (#{:?}, {:?}), parent={:?}, best={}" , commit_number, commit_hash, self . parent_hash, is_best) ;
315
314
let cache = & mut * cache;
315
+ // Filter out commiting block if any.
316
316
let enacted: Vec < _ > = enacted
317
317
. iter ( )
318
318
. filter ( |h| commit_hash. as_ref ( ) . map_or ( true , |p| * h != p) )
@@ -370,7 +370,7 @@ impl<H: Hasher, B: BlockT> CacheChanges<H, B> {
370
370
modifications. insert ( k) ;
371
371
}
372
372
373
- // Save modified storage. These are ordered by the block number.
373
+ // Save modified storage. These are ordered by the block number in reverse .
374
374
let block_changes = BlockChanges {
375
375
storage : modifications,
376
376
child_storage : child_modifications,
@@ -427,10 +427,10 @@ impl<H: Hasher, S: StateBackend<H>, B: BlockT> CachingState<H, S, B> {
427
427
}
428
428
Some ( ref parent) => parent,
429
429
} ;
430
- // Ignore all storage modified in later blocks
430
+ // Ignore all storage entries modified in later blocks.
431
431
// Modifications contains block ordered by the number
432
432
// We search for our parent in that list first and then for
433
- // all its parent until we hit the canonical block,
433
+ // all its parents until we hit the canonical block,
434
434
// checking against all the intermediate modifications.
435
435
for m in modifications {
436
436
if & m. hash == parent {
0 commit comments