From b2cdfd2e3e186b9d6d1fd45bd9eb739b02cd9e9a Mon Sep 17 00:00:00 2001 From: pls148 <184445976+pls148@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:19:04 -0800 Subject: [PATCH] #4082 add mutable accessors to QuorumProposalWrapper --- crates/types/src/data.rs | 53 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/crates/types/src/data.rs b/crates/types/src/data.rs index 33c44567c6..b368ef466f 100644 --- a/crates/types/src/data.rs +++ b/crates/types/src/data.rs @@ -560,6 +560,19 @@ impl ViewChangeEvidence2 { } } +impl Committable for ViewChangeEvidence2 { + fn commit(&self) -> committable::Commitment { + let mut cb = RawCommitmentBuilder::new("ViewChangeEvidence2"); + + match self { + Self::Timeout(x) => cb = cb.field("timeout", x.commit()), + Self::ViewSync(x) => cb = cb.field("viewsync", x.commit()), + } + + cb.finalize() + } +} + /// Proposal to append a block. #[derive(derive_more::Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] #[serde(bound(deserialize = ""))] @@ -630,35 +643,70 @@ impl QuorumProposalWrapper { &self.proposal.block_header } + /// Helper function to get the proposal's block_header + pub fn block_header_mut(&mut self) -> &mut TYPES::BlockHeader { + &mut self.proposal.block_header + } + /// Helper function to get the proposal's view_number pub fn view_number(&self) -> TYPES::View { self.proposal.view_number } + /// Helper function to get the proposal's view_number + pub fn view_number_mut(&mut self) -> &mut TYPES::View { + &mut self.proposal.view_number + } + /// Helper function to get the proposal's justify_qc pub fn justify_qc(&self) -> &QuorumCertificate2 { &self.proposal.justify_qc } + /// Helper function to get the proposal's justify_qc + pub fn justify_qc_mut(&mut self) -> &mut QuorumCertificate2 { + &mut self.proposal.justify_qc + } + /// Helper function to get the proposal's next_epoch_justify_qc pub fn next_epoch_justify_qc(&self) -> &Option> { &self.proposal.next_epoch_justify_qc } + /// Helper function to get the proposal's next_epoch_justify_qc + pub fn next_epoch_justify_qc_mut(&mut self) -> &mut Option> { + &mut self.proposal.next_epoch_justify_qc + } + /// Helper function to get the proposal's upgrade_certificate pub fn upgrade_certificate(&self) -> &Option> { &self.proposal.upgrade_certificate } + /// Helper function to get the proposal's upgrade_certificate + pub fn upgrade_certificate_mut(&mut self) -> &mut Option> { + &mut self.proposal.upgrade_certificate + } + /// Helper function to get the proposal's view_change_evidence pub fn view_change_evidence(&self) -> &Option> { &self.proposal.view_change_evidence } + /// Helper function to get the proposal's view_change_evidence + pub fn view_change_evidence_mut(&mut self) -> &mut Option> { + &mut self.proposal.view_change_evidence + } + /// Helper function to get the proposal's next_drb_result pub fn next_drb_result(&self) -> &Option { &self.proposal.next_drb_result } + + /// Helper function to get the proposal's next_drb_result + pub fn next_drb_result_mut(&mut self) -> &mut Option { + &mut self.proposal.next_drb_result + } } impl From> for QuorumProposalWrapper { @@ -1084,7 +1132,7 @@ impl Committable for Leaf2 { block_header, upgrade_certificate, block_payload: _, - view_change_evidence: _, + view_change_evidence, next_drb_result, with_epoch, } = self; @@ -1099,7 +1147,8 @@ impl Committable for Leaf2 { if *with_epoch { cb = cb .constant_str("with_epoch") - .optional("next_epoch_justify_qc", next_epoch_justify_qc); + .optional("next_epoch_justify_qc", next_epoch_justify_qc) + .optional("view_change_evidence", view_change_evidence); if let Some(next_drb_result) = next_drb_result { cb = cb