openmina_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)]
11pub struct SnarkJobCommitment {
12 timestamp: u64,
13 pub job_id: SnarkJobId,
14 pub fee: CurrencyFeeStableV1,
15 pub snarker: NonZeroCurvePoint,
16 }
18
19impl SnarkJobCommitment {
20 pub fn new(
21 timestamp: u64,
22 job_id: SnarkJobId,
23 fee: CurrencyFeeStableV1,
24 snarker: NonZeroCurvePoint,
25 ) -> Self {
26 Self {
27 timestamp,
28 job_id,
29 fee,
30 snarker,
31 }
34 }
35
36 pub fn timestamp(&self) -> Timestamp {
37 Timestamp::new(self.timestamp * 1_000_000)
38 }
39
40 pub fn tie_breaker_hash(&self) -> [u8; 32] {
41 super::tie_breaker_hash(&self.job_id, &self.snarker)
42 }
43}