pub struct ValidateHostAccess {
    pub workspace: HostFnWorkspaceRead,
    pub network: HolochainP2pDna,
}

Fields§

§workspace: HostFnWorkspaceRead§network: HolochainP2pDna

Implementations§

Examples found in repository?
src/core/workflow/app_validation_workflow.rs (line 589)
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
async fn run_validation_callback_inner<R>(
    invocation: ValidateInvocation,
    ribosome: &R,
    workspace_read: HostFnWorkspaceRead,
    network: HolochainP2pDna,
    (mut fetched_deps, recursion_depth): (HashSet<AnyDhtHash>, usize),
    mut visited_activity: HashSet<ChainFilter>,
) -> AppValidationResult<Outcome>
where
    R: RibosomeT,
{
    let validate_result = ribosome.run_validate(
        ValidateHostAccess::new(workspace_read.clone(), network.clone()),
        invocation.clone(),
    )?;
    match validate_result {
        ValidateResult::Valid => Ok(Outcome::Accepted),
        ValidateResult::Invalid(reason) => Ok(Outcome::Rejected(reason)),
        ValidateResult::UnresolvedDependencies(UnresolvedDependencies::Hashes(hashes)) => {
            // This is the base case where we've been recursing and start seeing
            // all the same hashes unresolved that we already tried to fetch.
            // At this point we should just give up on the inline recursing and
            // let some future background task attempt to fetch these hashes
            // again. Hopefully by then the hashes are fetchable.
            // 20 is a completely arbitrary max recursion depth.
            if recursion_depth > 20 || hashes.iter().all(|hash| fetched_deps.contains(hash)) {
                Ok(Outcome::AwaitingDeps(hashes))
            } else {
                let in_flight = hashes.into_iter().map(|hash| async {
                    let cascade_workspace = workspace_read.clone();
                    let mut cascade =
                        Cascade::from_workspace_and_network(&cascade_workspace, network.clone());
                    cascade
                        .fetch_record(hash.clone(), NetworkGetOptions::must_get_options())
                        .await?;
                    Ok(hash)
                });
                let results: Vec<_> = futures::stream::iter(in_flight)
                    // 10 is completely arbitrary.
                    .buffered(10)
                    .collect()
                    .await;
                let results: AppValidationResult<Vec<_>> = results.into_iter().collect();
                for hash in results? {
                    fetched_deps.insert(hash);
                }
                run_validation_callback_inner(
                    invocation,
                    ribosome,
                    workspace_read,
                    network,
                    (fetched_deps, recursion_depth + 1),
                    visited_activity,
                )
                .await
            }
        }
        ValidateResult::UnresolvedDependencies(UnresolvedDependencies::AgentActivity(
            author,
            filter,
        )) => {
            if recursion_depth > 20 || visited_activity.contains(&filter) {
                Ok(Outcome::AwaitingDeps(vec![author.into()]))
            } else {
                let cascade_workspace = workspace_read.clone();
                let mut cascade =
                    Cascade::from_workspace_and_network(&cascade_workspace, network.clone());
                cascade
                    .must_get_agent_activity(author.clone(), filter.clone())
                    .await?;
                visited_activity.insert(filter);
                run_validation_callback_inner(
                    invocation,
                    ribosome,
                    workspace_read,
                    network,
                    (fetched_deps, recursion_depth + 1),
                    visited_activity,
                )
                .await
            }
        }
    }
}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
upcast ref
upcast mut ref
upcast boxed dyn
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more