@@ -875,84 +875,63 @@ impl State {
875875 pub fn handle_tx_certificates ( & mut self , tx_certs_msg : & TxCertificatesMessage ) -> Result < ( ) > {
876876 // Handle certificates
877877 for tx_cert in tx_certs_msg. certificates . iter ( ) {
878- match tx_cert {
878+ match & tx_cert. cert {
879879 TxCertificate :: StakeRegistration ( reg) => {
880- self . register_stake_address ( & reg. stake_address , None ) ;
880+ self . register_stake_address ( & reg, None ) ;
881881 }
882882
883883 TxCertificate :: StakeDeregistration ( dreg) => {
884- self . deregister_stake_address ( & dreg. stake_address , None ) ;
884+ self . deregister_stake_address ( & dreg, None ) ;
885885 }
886886
887887 TxCertificate :: MoveInstantaneousReward ( mir) => {
888- self . handle_mir ( & mir. cert ) . unwrap_or_else ( |e| error ! ( "MIR failed: {e:#}" ) ) ;
888+ self . handle_mir ( & mir) . unwrap_or_else ( |e| error ! ( "MIR failed: {e:#}" ) ) ;
889889 }
890890
891891 TxCertificate :: Registration ( reg) => {
892- self . register_stake_address ( & reg. cert . stake_address , Some ( reg. cert . deposit ) ) ;
892+ self . register_stake_address ( & reg. stake_address , Some ( reg. deposit ) ) ;
893893 }
894894
895895 TxCertificate :: Deregistration ( dreg) => {
896- self . deregister_stake_address ( & dreg. cert . stake_address , Some ( dreg. cert . refund ) ) ;
896+ self . deregister_stake_address ( & dreg. stake_address , Some ( dreg. refund ) ) ;
897897 }
898898
899899 TxCertificate :: StakeDelegation ( delegation) => {
900- self . record_stake_delegation (
901- & delegation. cert . stake_address ,
902- & delegation. cert . operator ,
903- ) ;
900+ self . record_stake_delegation ( & delegation. stake_address , & delegation. operator ) ;
904901 }
905902
906903 TxCertificate :: VoteDelegation ( delegation) => {
907904 self . record_drep_delegation ( & delegation. stake_address , & delegation. drep ) ;
908905 }
909906
910907 TxCertificate :: StakeAndVoteDelegation ( delegation) => {
911- self . record_stake_delegation (
912- & delegation. cert . stake_address ,
913- & delegation. cert . operator ,
914- ) ;
915- self . record_drep_delegation (
916- & delegation. cert . stake_address ,
917- & delegation. cert . drep ,
918- ) ;
908+ self . record_stake_delegation ( & delegation. stake_address , & delegation. operator ) ;
909+ self . record_drep_delegation ( & delegation. stake_address , & delegation. drep ) ;
919910 }
920911
921912 TxCertificate :: StakeRegistrationAndDelegation ( delegation) => {
922913 self . register_stake_address (
923- & delegation. cert . stake_address ,
924- Some ( delegation. cert . deposit ) ,
925- ) ;
926- self . record_stake_delegation (
927- & delegation. cert . stake_address ,
928- & delegation. cert . operator ,
914+ & delegation. stake_address ,
915+ Some ( delegation. deposit ) ,
929916 ) ;
917+ self . record_stake_delegation ( & delegation. stake_address , & delegation. operator ) ;
930918 }
931919
932920 TxCertificate :: StakeRegistrationAndVoteDelegation ( delegation) => {
933921 self . register_stake_address (
934- & delegation. cert . stake_address ,
935- Some ( delegation. cert . deposit ) ,
936- ) ;
937- self . record_drep_delegation (
938- & delegation. cert . stake_address ,
939- & delegation. cert . drep ,
922+ & delegation. stake_address ,
923+ Some ( delegation. deposit ) ,
940924 ) ;
925+ self . record_drep_delegation ( & delegation. stake_address , & delegation. drep ) ;
941926 }
942927
943928 TxCertificate :: StakeRegistrationAndStakeAndVoteDelegation ( delegation) => {
944929 self . register_stake_address (
945- & delegation. cert . stake_address ,
946- Some ( delegation. cert . deposit ) ,
947- ) ;
948- self . record_stake_delegation (
949- & delegation. cert . stake_address ,
950- & delegation. cert . operator ,
951- ) ;
952- self . record_drep_delegation (
953- & delegation. cert . stake_address ,
954- & delegation. cert . drep ,
930+ & delegation. stake_address ,
931+ Some ( delegation. deposit ) ,
955932 ) ;
933+ self . record_stake_delegation ( & delegation. stake_address , & delegation. operator ) ;
934+ self . record_drep_delegation ( & delegation. stake_address , & delegation. drep ) ;
956935 }
957936
958937 _ => ( ) ,
@@ -1013,11 +992,10 @@ mod tests {
1013992 use acropolis_common:: {
1014993 protocol_params:: ConwayParams , rational_number:: RationalNumber , Anchor , Committee ,
1015994 Constitution , CostModel , DRepVotingThresholds , NetworkId , PoolVotingThresholds , Pot ,
1016- PotDelta , Ratio , Registration , RegistrationWithPos , StakeAddress , StakeAddressDelta ,
1017- StakeAndVoteDelegation , StakeAndVoteDelegationWithPos , StakeCredential ,
1018- StakeRegistrationAndStakeAndVoteDelegation ,
1019- StakeRegistrationAndStakeAndVoteDelegationWithPos , StakeRegistrationAndVoteDelegation ,
1020- StakeRegistrationAndVoteDelegationWithPos , TxIdentifier , VoteDelegation , Withdrawal ,
995+ PotDelta , Ratio , Registration , StakeAddress , StakeAddressDelta , StakeAndVoteDelegation ,
996+ StakeCredential , StakeRegistrationAndStakeAndVoteDelegation ,
997+ StakeRegistrationAndVoteDelegation , TxCertificateWithPos , TxIdentifier , VoteDelegation ,
998+ Withdrawal ,
1021999 } ;
10221000
10231001 // Helper to create a StakeAddress from a byte slice
@@ -1390,57 +1368,66 @@ mod tests {
13901368 let spo3 = create_address ( & [ 0x03 ] ) ;
13911369 let spo4 = create_address ( & [ 0x04 ] ) ;
13921370
1371+ let tx_identifier = TxIdentifier :: default ( ) ;
1372+
13931373 let certificates = vec ! [
13941374 // register the first two SPOs separately from their delegation
1395- TxCertificate :: Registration ( RegistrationWithPos {
1396- cert: Registration {
1375+ TxCertificateWithPos {
1376+ cert: TxCertificate :: Registration ( Registration {
13971377 stake_address: spo1. clone( ) ,
13981378 deposit: 1 ,
1399- } ,
1400- tx_identifier: TxIdentifier :: default ( ) ,
1379+ } ) ,
1380+ tx_identifier,
14011381 cert_index: 0 ,
1402- } ) ,
1403- TxCertificate :: Registration ( RegistrationWithPos {
1404- cert: Registration {
1382+ } ,
1383+ TxCertificateWithPos {
1384+ cert: TxCertificate :: Registration ( Registration {
14051385 stake_address: spo2. clone( ) ,
14061386 deposit: 1 ,
1407- } ,
1408- tx_identifier: TxIdentifier :: default ( ) ,
1387+ } ) ,
1388+ tx_identifier,
14091389 cert_index: 0 ,
1410- } ) ,
1411- TxCertificate :: VoteDelegation ( VoteDelegation {
1412- stake_address: spo1. clone( ) ,
1413- drep: DRepChoice :: Key ( DREP_HASH . to_vec( ) ) ,
1414- } ) ,
1415- TxCertificate :: StakeAndVoteDelegation ( StakeAndVoteDelegationWithPos {
1416- cert: StakeAndVoteDelegation {
1390+ } ,
1391+ TxCertificateWithPos {
1392+ cert: TxCertificate :: VoteDelegation ( VoteDelegation {
1393+ stake_address: spo1. clone( ) ,
1394+ drep: DRepChoice :: Key ( DREP_HASH . to_vec( ) ) ,
1395+ } ) ,
1396+ tx_identifier,
1397+ cert_index: 0 ,
1398+ } ,
1399+ TxCertificateWithPos {
1400+ cert: TxCertificate :: StakeAndVoteDelegation ( StakeAndVoteDelegation {
14171401 stake_address: spo2. clone( ) ,
14181402 operator: spo1. get_hash( ) . to_vec( ) ,
14191403 drep: DRepChoice :: Script ( DREP_HASH . to_vec( ) ) ,
1420- } ,
1421- tx_identifier: TxIdentifier :: default ( ) ,
1422- } ) ,
1423- TxCertificate :: StakeRegistrationAndVoteDelegation (
1424- StakeRegistrationAndVoteDelegationWithPos {
1425- cert: StakeRegistrationAndVoteDelegation {
1404+ } ) ,
1405+ tx_identifier,
1406+ cert_index: 0 ,
1407+ } ,
1408+ TxCertificateWithPos {
1409+ cert: TxCertificate :: StakeRegistrationAndVoteDelegation (
1410+ StakeRegistrationAndVoteDelegation {
14261411 stake_address: spo3. clone( ) ,
14271412 drep: DRepChoice :: Abstain ,
14281413 deposit: 1 ,
14291414 } ,
1430- tx_identifier: TxIdentifier :: default ( ) ,
1431- } ,
1432- ) ,
1433- TxCertificate :: StakeRegistrationAndStakeAndVoteDelegation (
1434- StakeRegistrationAndStakeAndVoteDelegationWithPos {
1435- cert: StakeRegistrationAndStakeAndVoteDelegation {
1415+ ) ,
1416+ tx_identifier,
1417+ cert_index: 0 ,
1418+ } ,
1419+ TxCertificateWithPos {
1420+ cert: TxCertificate :: StakeRegistrationAndStakeAndVoteDelegation (
1421+ StakeRegistrationAndStakeAndVoteDelegation {
14361422 stake_address: spo4. clone( ) ,
14371423 operator: spo1. get_hash( ) . to_vec( ) ,
14381424 drep: DRepChoice :: NoConfidence ,
14391425 deposit: 1 ,
14401426 } ,
1441- tx_identifier: TxIdentifier :: default ( ) ,
1442- } ,
1443- ) ,
1427+ ) ,
1428+ tx_identifier,
1429+ cert_index: 0 ,
1430+ } ,
14441431 ] ;
14451432
14461433 state. handle_tx_certificates ( & TxCertificatesMessage { certificates } ) ?;
0 commit comments