Skip to content

Commit

Permalink
alonzo.cddl minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
rooooooooob committed Dec 30, 2021
1 parent 531e8cc commit 627c35f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,8 @@ pub struct ProtocolParamUpdate {
max_tx_ex_units: Option<ExUnits>,
max_block_ex_units: Option<ExUnits>,
max_value_size: Option<u32>,
collateral_percentage: Option<u32>,
max_collateral_inputs: Option<u32>,
}

to_from_bytes!(ProtocolParamUpdate);
Expand Down Expand Up @@ -2113,6 +2115,22 @@ impl ProtocolParamUpdate {
self.max_value_size.clone()
}

pub fn set_collateral_percentage(&mut self, collateral_percentage: u32) {
self.collateral_percentage = Some(collateral_percentage)
}

pub fn collateral_percentage(&self) -> Option<u32> {
self.collateral_percentage.clone()
}

pub fn set_max_collateral_inputs(&mut self, max_collateral_inputs: u32) {
self.max_collateral_inputs = Some(max_collateral_inputs)
}

pub fn max_collateral_inputs(&self) -> Option<u32> {
self.max_collateral_inputs.clone()
}

pub fn new() -> Self {
Self {
minfee_a: None,
Expand All @@ -2137,6 +2155,8 @@ impl ProtocolParamUpdate {
max_tx_ex_units: None,
max_block_ex_units: None,
max_value_size: None,
collateral_percentage: None,
max_collateral_inputs: None,
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions rust/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,14 @@ impl cbor_event::se::Serialize for ProtocolParamUpdate {
serializer.write_unsigned_integer(22)?;
field.serialize(serializer)?;
}
if let Some(field) = &self.collateral_percentage {
serializer.write_unsigned_integer(23)?;
field.serialize(serializer)?;
}
if let Some(field) = &self.max_collateral_inputs {
serializer.write_unsigned_integer(24)?;
field.serialize(serializer)?;
}
Ok(serializer)
}
}
Expand Down Expand Up @@ -2673,6 +2681,8 @@ impl Deserialize for ProtocolParamUpdate {
let mut max_tx_ex_units = None;
let mut max_block_ex_units = None;
let mut max_value_size = None;
let mut collateral_percentage = None;
let mut max_collateral_inputs = None;
let mut read = 0;
while match len { cbor_event::Len::Len(n) => read < n as usize, cbor_event::Len::Indefinite => true, } {
match raw.cbor_type()? {
Expand Down Expand Up @@ -2875,6 +2885,24 @@ impl Deserialize for ProtocolParamUpdate {
Ok(u32::deserialize(raw)?)
})().map_err(|e| e.annotate("max_value_size"))?);
},
23 => {
if collateral_percentage.is_some() {
return Err(DeserializeFailure::DuplicateKey(Key::Uint(23)).into());
}
collateral_percentage = Some((|| -> Result<_, DeserializeError> {
read_len.read_elems(1)?;
Ok(u32::deserialize(raw)?)
})().map_err(|e| e.annotate("collateral_percentage"))?);
},
24 => {
if max_collateral_inputs.is_some() {
return Err(DeserializeFailure::DuplicateKey(Key::Uint(24)).into());
}
max_collateral_inputs = Some((|| -> Result<_, DeserializeError> {
read_len.read_elems(1)?;
Ok(u32::deserialize(raw)?)
})().map_err(|e| e.annotate("max_collateral_inputs"))?);
},
unknown_key => return Err(DeserializeFailure::UnknownKey(Key::Uint(unknown_key)).into()),
},
CBORType::Text => match raw.text()?.as_str() {
Expand Down Expand Up @@ -2915,6 +2943,8 @@ impl Deserialize for ProtocolParamUpdate {
max_tx_ex_units,
max_block_ex_units,
max_value_size,
collateral_percentage,
max_collateral_inputs,
})
})().map_err(|e| e.annotate("ProtocolParamUpdate"))
}
Expand Down

0 comments on commit 627c35f

Please sign in to comment.