/// Pushes the state sync data to the cache without checking that
/// the new state is newer that the stored one.
///
/// This function is not public and therefore cannot be called directly.
Pushes the state sync data to the cache without checking that
the new state is newer that the stored one.

This function is not public and therefore cannot be called directly.
Pushes the state sync data to the cache without checking that the new state is newer that the stored one . This function is not public and therefore cannot be called directly .
fn push_inner(
        &mut self,
        sync: &IncompleteState,
        manifest: Manifest,
        fetch_chunks: HashSet<usize>,
    ) {
        // fetch_chunks, as stored by IncompleteState considers the manifest as chunk 0
        // For the cache we store indices into the manifest's chunk table as
        // missing_chunks.
        debug_assert!(!fetch_chunks.contains(&0));
        let missing_chunks = fetch_chunks.into_iter().map(|i| i - 1).collect();
        // We rename the folder to decouple the cache from active state syncs a bit.
        // Otherwise we'd have to assume that there won't be an active state sync at
        // the same height as the cache (as the folder name
        // only depends on the height).
        let cache_root = sync
            .state_layout
            .state_sync_cache(sync.height)
            .expect("failed to create directory for state sync cache");
        if let Err(err) = std::fs::rename(&sync.root, &cache_root) {
            warn!(
                self.log,
                "Failed to create state sync cache at {}: {}",
                cache_root.display(),
                err
            );
            // On error, make sure the cache is empty and clean up
            self.entry = None;
            delete_folder(&self.log, &cache_root);
            delete_folder(&self.log, &sync.root);
            return;
        }
        let entry = StateSyncCacheEntry {
            manifest,
            height: sync.height,
            path: cache_root,
            missing_chunks,
            log: self.log.clone(),
        };
        self.entry = Some(Arc::new(entry));
    }
fn push_inner ( & mut self , sync : & IncompleteState , manifest : Manifest , fetch_chunks : HashSet < usize > , ) { // fetch_chunks, as stored by IncompleteState considers the manifest as chunk 0 // For the cache we store indices into the manifest's chunk table as // missing_chunks. debug_assert ! ( fetch_chunks contains ( 0 ) ) ; let missing_chunks = fetch_chunks . into_iter ( ) . map ( | i | i - 1 ) . collect ( ) ; // We rename the folder to decouple the cache from active state syncs a bit. // Otherwise we'd have to assume that there won't be an active state sync at // the same height as the cache (as the folder name // only depends on the height). let cache_root = sync . state_layout . state_sync_cache ( sync . height ) . expect ( " " ) ; if let Err ( err ) = std :: fs :: rename ( & sync . root , & cache_root ) { warn ! ( self log " " cache_root display ( ) err ) ; // On error, make sure the cache is empty and clean up self . entry = None ; delete_folder ( & self . log , & cache_root ) ; delete_folder ( & self . log , & sync . root ) ; return ; } let entry = StateSyncCacheEntry { manifest , height : sync . height , path : cache_root , missing_chunks , log : self . log . clone ( ) , } ; self . entry = Some ( Arc :: new ( entry ) ) ; }
Pushes the state sync data to the cache without checking that
the new state is newer that the stored one.
Pushes the state sync data to the cache without checking that the new state is newer that the stored one .
&mut self
sync
&IncompleteState
manifest
Manifest
fetch_chunks
HashSet<usize>