fn store_validation_result(
    storage_account: &mut StorageAccount,
    segment: usize,
    checked_proof: CheckedProof,
) -> Result<(), InstructionError> {
    let mut storage_contract = storage_account.account.state()?;
    match &mut storage_contract {
        StorageContract::ReplicatorStorage {
            proofs,
            reward_validations,
            ..
        } => {
            if !proofs.contains_key(&segment) {
                return Err(InstructionError::InvalidAccountData);
            }

            if proofs
                .get(&segment)
                .unwrap()
                .contains_key(&checked_proof.proof.sha_state)
            {
                reward_validations
                    .entry(segment)
                    .or_default()
                    .entry(checked_proof.proof.sha_state)
                    .or_default()
                    .push(checked_proof.status);
            } else {
                return Err(InstructionError::InvalidAccountData);
            }
        }
        _ => return Err(InstructionError::InvalidAccountData),
    }
    storage_account.account.set_state(&storage_contract)
}
/// Store the result of a proof validation into the replicator account
Store the result of a proof validation into the replicator account
Store the result of a proof validation into the replicator account
fn store_validation_result(
    storage_account: &mut StorageAccount,
    segment: usize,
    checked_proof: CheckedProof,
) -> Result<(), InstructionError> {
    let mut storage_contract = storage_account.account.state()?;
    match &mut storage_contract {
        StorageContract::ReplicatorStorage {
            proofs,
            reward_validations,
            ..
        } => {
            if !proofs.contains_key(&segment) {
                return Err(InstructionError::InvalidAccountData);
            }
            if proofs
                .get(&segment)
                .unwrap()
                .contains_key(&checked_proof.proof.sha_state)
            {
                reward_validations
                    .entry(segment)
                    .or_default()
                    .entry(checked_proof.proof.sha_state)
                    .or_default()
                    .push(checked_proof.status);
            } else {
                return Err(InstructionError::InvalidAccountData);
            }
        }
        _ => return Err(InstructionError::InvalidAccountData),
    }
    storage_account.account.set_state(&storage_contract)
}
fn store_validation_result ( storage_account : & mut StorageAccount , segment : usize , checked_proof : CheckedProof , ) -> Result < ( ) , InstructionError > { let mut storage_contract = storage_account . account . state ( ) ? ; match & mut storage_contract { StorageContract :: ReplicatorStorage { proofs , reward_validations , .. } => { if ! proofs . contains_key ( & segment ) { return Err ( InstructionError :: InvalidAccountData ) ; } if proofs . get ( & segment ) . unwrap ( ) . contains_key ( & checked_proof . proof . sha_state ) { reward_validations . entry ( segment ) . or_default ( ) . entry ( checked_proof . proof . sha_state ) . or_default ( ) . push ( checked_proof . status ) ; } else { return Err ( InstructionError :: InvalidAccountData ) ; } } _ => return Err ( InstructionError :: InvalidAccountData ) , } storage_account . account . set_state ( & storage_contract ) }
Store the result of a proof validation into the replicator account
Store the result of a proof validation into the replicator account
storage_account
&mut StorageAccount
segment
usize
checked_proof
CheckedProof
storage_account
&mut StorageAccount
segment
usize
checked_proof
CheckedProof