@@ -15,6 +15,7 @@ use mina_p2p_messages::{
1515 } ,
1616} ;
1717use mina_signer:: CompressedPubKey ;
18+ use openmina_core:: snark:: SnarkJobId ;
1819use sha2:: Sha256 ;
1920
2021use crate :: {
@@ -529,6 +530,16 @@ pub mod transaction_snark {
529530
530531 pub type Checked = Work ;
531532
533+ impl From < & openmina_core:: snark:: Snark > for Work {
534+ fn from ( value : & openmina_core:: snark:: Snark ) -> Self {
535+ Self {
536+ prover : ( & value. snarker ) . into ( ) ,
537+ fee : ( & value. fee ) . into ( ) ,
538+ proofs : ( & * value. proofs ) . into ( ) ,
539+ }
540+ }
541+ }
542+
532543 impl Work {
533544 pub fn statement ( & self ) -> Statement {
534545 self . proofs . map ( |p| {
@@ -2604,3 +2615,36 @@ impl TransactionsOrdered<Arc<TransactionWithWitness>> {
26042615pub enum Pass {
26052616 FirstPassLedgerHash ( Fp ) ,
26062617}
2618+
2619+ impl From < & OneOrTwo < AvailableJobMessage > > for SnarkJobId {
2620+ fn from ( value : & OneOrTwo < AvailableJobMessage > ) -> Self {
2621+ let ( first, second) = match value {
2622+ OneOrTwo :: One ( j) => ( j, j) ,
2623+ OneOrTwo :: Two ( ( j1, j2) ) => ( j1, j2) ,
2624+ } ;
2625+
2626+ let source = match first {
2627+ AvailableJobMessage :: Base ( base) => & base. statement . 0 . source ,
2628+ AvailableJobMessage :: Merge { left, .. } => & left. 0 . 0 . statement . source ,
2629+ } ;
2630+ let target = match second {
2631+ AvailableJobMessage :: Base ( base) => & base. statement . 0 . target ,
2632+ AvailableJobMessage :: Merge { right, .. } => & right. 0 . 0 . statement . target ,
2633+ } ;
2634+
2635+ ( source, target) . into ( )
2636+ }
2637+ }
2638+
2639+ impl From < & OneOrTwo < Statement < ( ) > > > for SnarkJobId {
2640+ fn from ( value : & OneOrTwo < Statement < ( ) > > ) -> Self {
2641+ let ( source, target) : (
2642+ mina_p2p_messages:: v2:: MinaStateBlockchainStateValueStableV2LedgerProofStatementSource ,
2643+ mina_p2p_messages:: v2:: MinaStateBlockchainStateValueStableV2LedgerProofStatementSource ,
2644+ ) = match value {
2645+ OneOrTwo :: One ( stmt) => ( ( & stmt. source ) . into ( ) , ( & stmt. target ) . into ( ) ) ,
2646+ OneOrTwo :: Two ( ( stmt1, stmt2) ) => ( ( & stmt1. source ) . into ( ) , ( & stmt2. target ) . into ( ) ) ,
2647+ } ;
2648+ ( & source, & target) . into ( )
2649+ }
2650+ }
0 commit comments