Struct holochain::core::ribosome::guest_callback::validate::ValidateHostAccess
source · pub struct ValidateHostAccess {
pub workspace: HostFnWorkspaceRead,
pub network: HolochainP2pDna,
}
Fields§
§workspace: HostFnWorkspaceRead
§network: HolochainP2pDna
Implementations§
source§impl ValidateHostAccess
impl ValidateHostAccess
sourcepub fn new(
workspace: HostFnWorkspaceRead,
network: HolochainP2pDna
) -> ValidateHostAccess
pub fn new(
workspace: HostFnWorkspaceRead,
network: HolochainP2pDna
) -> ValidateHostAccess
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§
source§impl Clone for ValidateHostAccess
impl Clone for ValidateHostAccess
source§fn clone(&self) -> ValidateHostAccess
fn clone(&self) -> ValidateHostAccess
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ValidateHostAccess
impl Debug for ValidateHostAccess
source§impl From<&ValidateHostAccess> for HostFnAccess
impl From<&ValidateHostAccess> for HostFnAccess
source§fn from(_: &ValidateHostAccess) -> Self
fn from(_: &ValidateHostAccess) -> Self
Converts to this type from the input type.
source§impl From<ValidateHostAccess> for HostContext
impl From<ValidateHostAccess> for HostContext
source§fn from(validate_host_access: ValidateHostAccess) -> Self
fn from(validate_host_access: ValidateHostAccess) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for ValidateHostAccess
impl Send for ValidateHostAccess
impl Sync for ValidateHostAccess
impl Unpin for ValidateHostAccess
impl !UnwindSafe for ValidateHostAccess
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
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
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref