Function holochain::core::workflow::sys_validation_workflow::counterfeit_check
source · pub async fn counterfeit_check(
signature: &Signature,
action: &Action
) -> SysValidationResult<()>
Expand description
Check if the op has valid signature and author. Ops that fail this check should be dropped.
Examples found in repository?
src/core/workflow/sys_validation_workflow.rs (line 481)
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 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
async fn sys_validate_record_inner(
record: &Record,
workspace: &SysValidationWorkspace,
network: HolochainP2pDna,
conductor_handle: &Conductor,
) -> SysValidationResult<()> {
let signature = record.signature();
let action = record.action();
let maybe_entry = record.entry().as_option();
counterfeit_check(signature, action).await?;
async fn validate(
action: &Action,
maybe_entry: Option<&Entry>,
workspace: &SysValidationWorkspace,
network: HolochainP2pDna,
conductor_handle: &Conductor,
) -> SysValidationResult<()> {
let incoming_dht_ops_sender = None;
store_record(action, workspace, network.clone()).await?;
if let Some((maybe_entry, EntryVisibility::Public)) =
&maybe_entry.and_then(|e| action.entry_type().map(|et| (e, et.visibility())))
{
store_entry(
(action)
.try_into()
.map_err(|_| ValidationOutcome::NotNewEntry(action.clone()))?,
maybe_entry,
conductor_handle,
workspace,
network.clone(),
)
.await?;
}
match action {
Action::Update(action) => {
register_updated_content(action, workspace, network, incoming_dht_ops_sender)
.await?;
}
Action::Delete(action) => {
register_deleted_entry_action(action, workspace, network, incoming_dht_ops_sender)
.await?;
}
Action::CreateLink(action) => {
register_add_link(action, workspace, network, incoming_dht_ops_sender).await?;
}
Action::DeleteLink(action) => {
register_delete_link(action, workspace, network, incoming_dht_ops_sender).await?;
}
_ => {}
}
Ok(())
}
match maybe_entry {
Some(Entry::CounterSign(session, _)) => {
if let Some(weight) = action.entry_rate_data() {
let entry_hash = EntryHash::with_data_sync(maybe_entry.unwrap());
for action in session.build_action_set(entry_hash, weight)? {
validate(
&action,
maybe_entry,
workspace,
network.clone(),
conductor_handle,
)
.await?;
}
Ok(())
} else {
tracing::error!("Got countersigning entry without rate assigned. This should be impossible. But, let's see what happens.");
validate(action, maybe_entry, workspace, network, conductor_handle).await
}
}
_ => validate(action, maybe_entry, workspace, network, conductor_handle).await,
}
}