ccp_shared/proof/
raw.rs

1/*
2 * Copyright 2024 Fluence DAO
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use crate::types::*;
18use serde::Deserialize;
19use serde::Serialize;
20
21#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
22#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
23pub struct RawProof {
24    pub epoch: EpochParameters,
25    pub local_nonce: LocalNonce,
26    pub cu_id: CUID,
27    pub result_hash: ResultHash,
28}
29
30impl RawProof {
31    pub fn new(
32        epoch: EpochParameters,
33        local_nonce: LocalNonce,
34        cu_id: CUID,
35        result_hash: ResultHash,
36    ) -> Self {
37        Self {
38            epoch,
39            local_nonce,
40            cu_id,
41            result_hash,
42        }
43    }
44}
45
46use std::fmt;
47
48impl fmt::Display for RawProof {
49    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50        writeln!(f, "{}", self.epoch)?;
51        writeln!(f, "local nonce {:?}", self.local_nonce)?;
52        writeln!(f, "CU id: {:?}", self.cu_id)?;
53        writeln!(f, "result hash: {:?}", self.result_hash)
54    }
55}