@@ -515,11 +515,15 @@ impl Payload {
515515 }
516516 }
517517
518- fn verify_with_cache (
519- proofs : & [ ProofOfStore < BatchInfo > ] ,
518+ fn verify_with_cache < T > (
519+ proofs : & [ ProofOfStore < T > ] ,
520520 validator : & ValidatorVerifier ,
521521 proof_cache : & ProofCache ,
522- ) -> anyhow:: Result < ( ) > {
522+ ) -> anyhow:: Result < ( ) >
523+ where
524+ T : TBatchInfo + Send + Sync + ' static ,
525+ BatchInfoExt : From < T > ,
526+ {
523527 let unverified: Vec < _ > = proofs
524528 . iter ( )
525529 . filter ( |proof| {
@@ -535,15 +539,15 @@ impl Payload {
535539 Ok ( ( ) )
536540 }
537541
538- pub fn verify_inline_batches < ' a > (
539- inline_batches : impl Iterator < Item = ( & ' a BatchInfo , & ' a Vec < SignedTransaction > ) > ,
542+ pub fn verify_inline_batches < ' a , T : TBatchInfo + ' a > (
543+ inline_batches : impl Iterator < Item = ( & ' a T , & ' a Vec < SignedTransaction > ) > ,
540544 ) -> anyhow:: Result < ( ) > {
541545 for ( batch, payload) in inline_batches {
542546 // TODO: Can cloning be avoided here?
543547 let computed_digest = BatchPayload :: new ( batch. author ( ) , payload. clone ( ) ) . hash ( ) ;
544548 ensure ! (
545549 computed_digest == * batch. digest( ) ,
546- "Hash of the received inline batch doesn't match the digest value for batch {}: {} != {}" ,
550+ "Hash of the received inline batch doesn't match the digest value for batch {:? }: {} != {}" ,
547551 batch,
548552 computed_digest,
549553 batch. digest( )
@@ -552,9 +556,9 @@ impl Payload {
552556 Ok ( ( ) )
553557 }
554558
555- pub fn verify_opt_batches (
559+ pub fn verify_opt_batches < T : TBatchInfo > (
556560 verifier : & ValidatorVerifier ,
557- opt_batches : & OptBatches ,
561+ opt_batches : & OptBatches < T > ,
558562 ) -> anyhow:: Result < ( ) > {
559563 let authors = verifier. address_to_validator_index ( ) ;
560564 for batch in & opt_batches. batch_summary {
@@ -592,16 +596,26 @@ impl Payload {
592596 ) ?;
593597 Ok ( ( ) )
594598 } ,
595- ( true , Payload :: OptQuorumStore ( opt_quorum_store) ) => {
596- let proof_with_data = opt_quorum_store. proof_with_data ( ) ;
599+ ( true , Payload :: OptQuorumStore ( OptQuorumStorePayload :: V1 ( p) ) ) => {
600+ let proof_with_data = p. proof_with_data ( ) ;
601+ Self :: verify_with_cache ( & proof_with_data. batch_summary , verifier, proof_cache) ?;
602+ Self :: verify_inline_batches (
603+ p. inline_batches ( )
604+ . iter ( )
605+ . map ( |batch| ( batch. info ( ) , batch. transactions ( ) ) ) ,
606+ ) ?;
607+ Self :: verify_opt_batches ( verifier, p. opt_batches ( ) ) ?;
608+ Ok ( ( ) )
609+ } ,
610+ ( true , Payload :: OptQuorumStore ( OptQuorumStorePayload :: V2 ( p) ) ) => {
611+ let proof_with_data = p. proof_with_data ( ) ;
597612 Self :: verify_with_cache ( & proof_with_data. batch_summary , verifier, proof_cache) ?;
598613 Self :: verify_inline_batches (
599- opt_quorum_store
600- . inline_batches ( )
614+ p. inline_batches ( )
601615 . iter ( )
602616 . map ( |batch| ( batch. info ( ) , batch. transactions ( ) ) ) ,
603617 ) ?;
604- Self :: verify_opt_batches ( verifier, opt_quorum_store . opt_batches ( ) ) ?;
618+ Self :: verify_opt_batches ( verifier, p . opt_batches ( ) ) ?;
605619 Ok ( ( ) )
606620 } ,
607621 ( _, _) => Err ( anyhow:: anyhow!(
@@ -792,17 +806,28 @@ impl From<&Vec<&Payload>> for PayloadFilter {
792806 Payload :: DirectMempool ( _) => {
793807 error ! ( "DirectMempool payload in InQuorumStore filter" ) ;
794808 } ,
795- Payload :: OptQuorumStore ( opt_qs_payload ) => {
796- for batch in opt_qs_payload . inline_batches ( ) . iter ( ) {
809+ Payload :: OptQuorumStore ( OptQuorumStorePayload :: V1 ( p ) ) => {
810+ for batch in p . inline_batches ( ) . iter ( ) {
797811 exclude_batches. insert ( batch. info ( ) . clone ( ) . into ( ) ) ;
798812 }
799- for batch_info in & opt_qs_payload . opt_batches ( ) . batch_summary {
813+ for batch_info in & p . opt_batches ( ) . batch_summary {
800814 exclude_batches. insert ( batch_info. clone ( ) . into ( ) ) ;
801815 }
802- for proof in & opt_qs_payload . proof_with_data ( ) . batch_summary {
816+ for proof in & p . proof_with_data ( ) . batch_summary {
803817 exclude_batches. insert ( proof. info ( ) . clone ( ) . into ( ) ) ;
804818 }
805819 } ,
820+ Payload :: OptQuorumStore ( OptQuorumStorePayload :: V2 ( p) ) => {
821+ for batch in p. inline_batches ( ) . iter ( ) {
822+ exclude_batches. insert ( batch. info ( ) . clone ( ) ) ;
823+ }
824+ for batch_info in & p. opt_batches ( ) . batch_summary {
825+ exclude_batches. insert ( batch_info. clone ( ) ) ;
826+ }
827+ for proof in & p. proof_with_data ( ) . batch_summary {
828+ exclude_batches. insert ( proof. info ( ) . clone ( ) ) ;
829+ }
830+ } ,
806831 }
807832 }
808833 PayloadFilter :: InQuorumStore ( exclude_batches)
0 commit comments