mina_core/snark/
snark_job_commitment.rs1use mina_p2p_messages::{
2 binprot::macros::{BinProtRead, BinProtWrite},
3 v2::{CurrencyFeeStableV1, NonZeroCurvePoint},
4};
5use redux::Timestamp;
6use serde::{Deserialize, Serialize};
7
8use super::SnarkJobId;
9
10#[derive(BinProtWrite, BinProtRead, Serialize, Deserialize, Debug, Clone)]
11#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
12pub struct SnarkJobCommitment {
13 timestamp: u64,
14 pub job_id: SnarkJobId,
15 pub fee: CurrencyFeeStableV1,
16 pub snarker: NonZeroCurvePoint,
17 }
19
20impl SnarkJobCommitment {
21 pub fn new(
22 timestamp: u64,
23 job_id: SnarkJobId,
24 fee: CurrencyFeeStableV1,
25 snarker: NonZeroCurvePoint,
26 ) -> Self {
27 Self {
28 timestamp,
29 job_id,
30 fee,
31 snarker,
32 }
35 }
36
37 pub fn timestamp(&self) -> Timestamp {
38 Timestamp::new(self.timestamp * 1_000_000)
39 }
40
41 pub fn tie_breaker_hash(&self) -> [u8; 32] {
42 super::tie_breaker_hash(&self.job_id, &self.snarker)
43 }
44}