pub enum Outcome {
    Accepted,
    AwaitingDeps(Vec<AnyDhtHash>),
    Rejected(String),
}
Expand description

The outcome of sys validation

Variants§

§

Accepted

Moves to integration

§

AwaitingDeps(Vec<AnyDhtHash>)

Stays in limbo because a dependency needs is required to validate and could not be found

§

Rejected(String)

Moves to integration with status rejected

Implementations§

Helper function for creating awaiting deps and exiting when the dependency isn’t found

Examples found in repository?
src/core/workflow/app_validation_workflow.rs (line 345)
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
async fn dhtop_to_op(op: DhtOp, cascade: &mut Cascade) -> AppValidationOutcome<Op> {
    let op = match op {
        DhtOp::StoreRecord(signature, action, entry) => Op::StoreRecord(StoreRecord {
            record: Record::new(
                SignedActionHashed::with_presigned(
                    ActionHashed::from_content_sync(action),
                    signature,
                ),
                entry.map(|e| *e),
            ),
        }),
        DhtOp::StoreEntry(signature, action, entry) => Op::StoreEntry(StoreEntry {
            action: SignedHashed::new(action.into(), signature),
            entry: *entry,
        }),
        DhtOp::RegisterAgentActivity(signature, action) => {
            Op::RegisterAgentActivity(RegisterAgentActivity {
                action: SignedActionHashed::with_presigned(
                    ActionHashed::from_content_sync(action),
                    signature,
                ),
                cached_entry: None,
            })
        }
        DhtOp::RegisterUpdatedContent(signature, update, entry)
        | DhtOp::RegisterUpdatedRecord(signature, update, entry) => {
            let new_entry = match update.entry_type.visibility() {
                EntryVisibility::Public => match entry {
                    Some(entry) => Some(*entry),
                    None => Some(
                        cascade
                            .retrieve_entry(update.entry_hash.clone(), Default::default())
                            .await?
                            .map(|e| e.into_content())
                            .ok_or_else(|| Outcome::awaiting(&update.entry_hash))?,
                    ),
                },
                _ => None,
            };
            let original_entry = if let EntryVisibility::Public = update.entry_type.visibility() {
                Some(
                    cascade
                        .retrieve_entry(update.original_entry_address.clone(), Default::default())
                        .await?
                        .map(|e| e.into_content())
                        .ok_or_else(|| Outcome::awaiting(&update.original_entry_address))?,
                )
            } else {
                None
            };

            let original_action = cascade
                .retrieve_action(update.original_action_address.clone(), Default::default())
                .await?
                .and_then(|sh| {
                    NewEntryAction::try_from(sh.hashed.content)
                        .ok()
                        .map(|h| h.into())
                })
                .ok_or_else(|| Outcome::awaiting(&update.original_action_address))?;
            Op::RegisterUpdate(RegisterUpdate {
                update: SignedHashed::new(update, signature),
                new_entry,
                original_action,
                original_entry,
            })
        }
        DhtOp::RegisterDeletedBy(signature, delete)
        | DhtOp::RegisterDeletedEntryAction(signature, delete) => {
            let original_action: EntryCreationAction = cascade
                .retrieve_action(delete.deletes_address.clone(), Default::default())
                .await?
                .and_then(|sh| {
                    NewEntryAction::try_from(sh.hashed.content)
                        .ok()
                        .map(|h| h.into())
                })
                .ok_or_else(|| Outcome::awaiting(&delete.deletes_address))?;

            let original_entry = if let EntryVisibility::Public =
                original_action.entry_type().visibility()
            {
                Some(
                    cascade
                        .retrieve_entry(delete.deletes_entry_address.clone(), Default::default())
                        .await?
                        .map(|e| e.into_content())
                        .ok_or_else(|| Outcome::awaiting(&delete.deletes_entry_address))?,
                )
            } else {
                None
            };
            Op::RegisterDelete(RegisterDelete {
                delete: SignedHashed::new(delete, signature),
                original_action,
                original_entry,
            })
        }
        DhtOp::RegisterAddLink(signature, create_link) => {
            Op::RegisterCreateLink(RegisterCreateLink {
                create_link: SignedHashed::new(create_link, signature),
            })
        }
        DhtOp::RegisterRemoveLink(signature, delete_link) => {
            let create_link = cascade
                .retrieve_action(delete_link.link_add_address.clone(), Default::default())
                .await?
                .and_then(|sh| CreateLink::try_from(sh.hashed.content).ok())
                .ok_or_else(|| Outcome::awaiting(&delete_link.link_add_address))?;
            Op::RegisterDeleteLink(RegisterDeleteLink {
                delete_link: SignedHashed::new(delete_link, signature),
                create_link,
            })
        }
    };
    Ok(op)
}

Helper function for creating rejected outcomes

Examples found in repository?
src/core/workflow/app_validation_workflow.rs (lines 526-529)
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
pub fn entry_creation_zomes_to_invoke(
    action: &EntryCreationAction,
    ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
    match action {
        EntryCreationAction::Create(Create {
            entry_type: EntryType::App(app_entry_def),
            ..
        })
        | EntryCreationAction::Update(Update {
            entry_type: EntryType::App(app_entry_def),
            ..
        }) => {
            let zome = ribosome
                .get_integrity_zome(&app_entry_def.zome_index())
                .ok_or_else(|| {
                    Outcome::rejected(&format!(
                        "Zome does not exist for {:?}",
                        app_entry_def.zome_index()
                    ))
                })?;
            Ok(ZomesToInvoke::OneIntegrity(zome))
        }
        _ => Ok(ZomesToInvoke::AllIntegrity),
    }
}

fn create_link_zomes_to_invoke(
    create_link: &CreateLink,
    ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
    let zome = ribosome
        .get_integrity_zome(&create_link.zome_index)
        .ok_or_else(|| {
            Outcome::rejected(&format!(
                "Zome does not exist for {:?}",
                create_link.link_type
            ))
        })?;
    Ok(ZomesToInvoke::One(zome.erase_type()))
}

/// Get the zomes to invoke for an [`Op::StoreRecord`].
fn store_record_zomes_to_invoke(
    action: &Action,
    ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
    match action {
        Action::CreateLink(create_link) => create_link_zomes_to_invoke(create_link, ribosome),
        Action::Create(Create {
            entry_type: EntryType::App(AppEntryDef { zome_index, .. }),
            ..
        })
        | Action::Update(Update {
            entry_type: EntryType::App(AppEntryDef { zome_index, .. }),
            ..
        }) => {
            let zome = ribosome.get_integrity_zome(zome_index).ok_or_else(|| {
                Outcome::rejected(&format!("Zome does not exist for {:?}", zome_index))
            })?;
            Ok(ZomesToInvoke::OneIntegrity(zome))
        }
        _ => Ok(ZomesToInvoke::AllIntegrity),
    }
}

Exit early with an awaiting outcome

Early exits with an accepted outcome

Exit early with a rejected outcome

Trait Implementations§

Formats the value using the given formatter. Read more

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 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