pub(crate) fn handle_deduplicated_legacy_direct_deploy_request(
        &mut self,
        deploy_hash: DeployHash,
    ) -> Option<SharedObject<Vec<u8>>> {
        if self.enable_mem_deduplication {
            // On a cache hit, return directly from the cache.
            if let Some(serialized) = self.deploy_cache.get(&deploy_hash) {
                return Some(SharedObject::shared(serialized));
            }
        }

        let deploy = self.handle_legacy_direct_deploy_request(deploy_hash)?;

        match bincode::serialize(&deploy) {
            Ok(serialized) => {
                if self.enable_mem_deduplication {
                    // We found a deploy, ensure it gets added to the cache.
                    let arc = Arc::new(serialized);
                    self.deploy_cache.put(deploy_hash, Arc::downgrade(&arc));
                    Some(SharedObject::shared(arc))
                } else {
                    Some(SharedObject::owned(serialized))
                }
            }
            Err(err) => {
                // We failed to serialize a stored deploy, which is a serious issue. There is no
                // good recovery from this, so we just pretend we don't have it, logging an error.
                error!(
                    err = display_error(&err),
                    "failed to create (shared) get-response"
                );
                None
            }
        }
    }
/// Retrieves a potentially deduplicated deploy from the deploy store or cache, depending on
/// runtime configuration.
Retrieves a potentially deduplicated deploy from the deploy store or cache, depending on
runtime configuration.
Retrieves a potentially deduplicated deploy from the deploy store or cache depending on runtime configuration .
pub(crate) fn handle_deduplicated_legacy_direct_deploy_request(
        &mut self,
        deploy_hash: DeployHash,
    ) -> Option<SharedObject<Vec<u8>>> {
        if self.enable_mem_deduplication {
            // On a cache hit, return directly from the cache.
            if let Some(serialized) = self.deploy_cache.get(&deploy_hash) {
                return Some(SharedObject::shared(serialized));
            }
        }
        let deploy = self.handle_legacy_direct_deploy_request(deploy_hash)?;
        match bincode::serialize(&deploy) {
            Ok(serialized) => {
                if self.enable_mem_deduplication {
                    // We found a deploy, ensure it gets added to the cache.
                    let arc = Arc::new(serialized);
                    self.deploy_cache.put(deploy_hash, Arc::downgrade(&arc));
                    Some(SharedObject::shared(arc))
                } else {
                    Some(SharedObject::owned(serialized))
                }
            }
            Err(err) => {
                // We failed to serialize a stored deploy, which is a serious issue. There is no
                // good recovery from this, so we just pretend we don't have it, logging an error.
                error!(
                    err = display_error(&err),
                    "failed to create (shared) get-response"
                );
                None
            }
        }
    }
pub ( crate ) fn handle_deduplicated_legacy_direct_deploy_request ( & mut self , deploy_hash : DeployHash , ) -> Option < SharedObject < Vec < u8 > > > { if self . enable_mem_deduplication { // On a cache hit, return directly from the cache. if let Some ( serialized ) = self . deploy_cache . get ( & deploy_hash ) { return Some ( SharedObject :: shared ( serialized ) ) ; } } let deploy = self . handle_legacy_direct_deploy_request ( deploy_hash ) ? ; match bincode :: serialize ( & deploy ) { Ok ( serialized ) => { if self . enable_mem_deduplication { // We found a deploy, ensure it gets added to the cache. let arc = Arc :: new ( serialized ) ; self . deploy_cache . put ( deploy_hash , Arc :: downgrade ( & arc ) ) ; Some ( SharedObject :: shared ( arc ) ) } else { Some ( SharedObject :: owned ( serialized ) ) } } Err ( err ) => { // We failed to serialize a stored deploy, which is a serious issue. There is no // good recovery from this, so we just pretend we don't have it, logging an error. error ! ( err display_error ( err ) " " ) ; None } } }
Retrieves a potentially deduplicated deploy from the deploy store or cache, depending on
runtime configuration.
Retrieves a potentially deduplicated deploy from the deploy store or cache depending on runtime configuration .
&mut self
deploy_hash
DeployHash
&mut self
deploy_hash
DeployHash