pub async fn resolve_cells(
        self,
        agent: AgentPubKey,
        _gamut: SafGamut,
        membrane_proofs: HashMap<SlotId, MembraneProof>,
    ) -> AppBundleResult<CellSlotResolution> {
        let AppManifestValidated { name: _, slots } = self.manifest().clone().validate()?;
        let bundle = Arc::new(self);
        let tasks = slots.into_iter().map(|(slot_id, slot)| async {
            let bundle = bundle.clone();
            Ok((slot_id, bundle.resolve_cell(slot).await?))
        });
        let resolution = futures::future::join_all(tasks)
            .await
            .into_iter()
            .collect::<AppBundleResult<Vec<_>>>()?
            .into_iter()
            .fold(
                Ok(CellSlotResolution::new(agent.clone())),
                |acc: AppBundleResult<CellSlotResolution>, (slot_id, op)| {
                    if let Ok(mut resolution) = acc {
                        match op {
                            CellProvisioningOp::Create(saf, clone_limit) => {
                                let agent = resolution.agent.clone();
                                let saf_hash = saf.saf_hash().clone();
                                let cell_id = CellId::new(saf_hash, agent);
                                let slot = AppSlot::new(cell_id, true, clone_limit);
                                // TODO: could sequentialize this to remove the clone
                                let proof = membrane_proofs.get(&slot_id).cloned();
                                resolution.safs_to_register.push((saf, proof));
                                resolution.slots.push((slot_id, slot));
                            }
                            CellProvisioningOp::Existing(cell_id, clone_limit) => {
                                let slot = AppSlot::new(cell_id, true, clone_limit);
                                resolution.slots.push((slot_id, slot));
                            }
                            CellProvisioningOp::Noop(cell_id, clone_limit) => {
                                resolution
                                    .slots
                                    .push((slot_id, AppSlot::new(cell_id, false, clone_limit)));
                            }
                            other => {
                                tracing::error!(
                                    "Encountered unexpected CellProvisioningOp: {:?}",
                                    other
                                );
                                unimplemented!()
                            }
                        }
                        Ok(resolution)
                    } else {
                        acc
                    }
                },
            )?;

        // let resolution = cells.into_iter();
        Ok(resolution)
    }
/// Given a SafGamut, decide which of the available SAFs or Cells should be
/// used for each cell in this app.
Given a SafGamut, decide which of the available SAFs or Cells should be
used for each cell in this app.
Given a SafGamut decide which of the available SAFs or Cells should be used for each cell in this app .
pub async fn resolve_cells(
        self,
        agent: AgentPubKey,
        _gamut: SafGamut,
        membrane_proofs: HashMap<SlotId, MembraneProof>,
    ) -> AppBundleResult<CellSlotResolution> {
        let AppManifestValidated { name: _, slots } = self.manifest().clone().validate()?;
        let bundle = Arc::new(self);
        let tasks = slots.into_iter().map(|(slot_id, slot)| async {
            let bundle = bundle.clone();
            Ok((slot_id, bundle.resolve_cell(slot).await?))
        });
        let resolution = futures::future::join_all(tasks)
            .await
            .into_iter()
            .collect::<AppBundleResult<Vec<_>>>()?
            .into_iter()
            .fold(
                Ok(CellSlotResolution::new(agent.clone())),
                |acc: AppBundleResult<CellSlotResolution>, (slot_id, op)| {
                    if let Ok(mut resolution) = acc {
                        match op {
                            CellProvisioningOp::Create(saf, clone_limit) => {
                                let agent = resolution.agent.clone();
                                let saf_hash = saf.saf_hash().clone();
                                let cell_id = CellId::new(saf_hash, agent);
                                let slot = AppSlot::new(cell_id, true, clone_limit);
                                // TODO: could sequentialize this to remove the clone
                                let proof = membrane_proofs.get(&slot_id).cloned();
                                resolution.safs_to_register.push((saf, proof));
                                resolution.slots.push((slot_id, slot));
                            }
                            CellProvisioningOp::Existing(cell_id, clone_limit) => {
                                let slot = AppSlot::new(cell_id, true, clone_limit);
                                resolution.slots.push((slot_id, slot));
                            }
                            CellProvisioningOp::Noop(cell_id, clone_limit) => {
                                resolution
                                    .slots
                                    .push((slot_id, AppSlot::new(cell_id, false, clone_limit)));
                            }
                            other => {
                                tracing::error!(
                                    "Encountered unexpected CellProvisioningOp: {:?}",
                                    other
                                );
                                unimplemented!()
                            }
                        }
                        Ok(resolution)
                    } else {
                        acc
                    }
                },
            )?;
        // let resolution = cells.into_iter();
        Ok(resolution)
    }
pub async fn resolve_cells ( self , agent : AgentPubKey , _gamut : SafGamut , membrane_proofs : HashMap < SlotId , MembraneProof > , ) -> AppBundleResult < CellSlotResolution > { let AppManifestValidated { name : _ , slots } = self . manifest ( ) . clone ( ) . validate ( ) ? ; let bundle = Arc :: new ( self ) ; let tasks = slots . into_iter ( ) . map ( | ( slot_id , slot ) | async { let bundle = bundle . clone ( ) ; Ok ( ( slot_id , bundle . resolve_cell ( slot ) . await ? ) ) } ) ; let resolution = futures :: future :: join_all ( tasks ) . await . into_iter ( ) . collect :: < AppBundleResult < Vec < _ > > > ( ) ? . into_iter ( ) . fold ( Ok ( CellSlotResolution :: new ( agent . clone ( ) ) ) , | acc : AppBundleResult < CellSlotResolution > , ( slot_id , op ) | { if let Ok ( mut resolution ) = acc { match op { CellProvisioningOp :: Create ( saf , clone_limit ) => { let agent = resolution . agent . clone ( ) ; let saf_hash = saf . saf_hash ( ) . clone ( ) ; let cell_id = CellId :: new ( saf_hash , agent ) ; let slot = AppSlot :: new ( cell_id , true , clone_limit ) ; // TODO: could sequentialize this to remove the clone let proof = membrane_proofs . get ( & slot_id ) . cloned ( ) ; resolution . safs_to_register . push ( ( saf , proof ) ) ; resolution . slots . push ( ( slot_id , slot ) ) ; } CellProvisioningOp :: Existing ( cell_id , clone_limit ) => { let slot = AppSlot :: new ( cell_id , true , clone_limit ) ; resolution . slots . push ( ( slot_id , slot ) ) ; } CellProvisioningOp :: Noop ( cell_id , clone_limit ) => { resolution . slots . push ( ( slot_id , AppSlot :: new ( cell_id , false , clone_limit ) ) ) ; } other => { tracing :: error ! ( " " other ) ; unimplemented ! ( ) } } Ok ( resolution ) } else { acc } } , ) ? ; // let resolution = cells.into_iter(); Ok ( resolution ) }
Given a SafGamut, decide which of the available SAFs or Cells should be
used for each cell in this app.
Given a SafGamut decide which of the available SAFs or Cells should be used for each cell in this app .
self
agent
AgentPubKey
_gamut
SafGamut
membrane_proofs
HashMap<SlotId, MembraneProof>
self
agent
AgentPubKey
_gamut
SafGamut
membrane_proofs
HashMap<SlotId, MembraneProof>