feat(traverse): introduce small QoL improvements (#567)

This commit is contained in:
Santiago Carmuega 2024-12-29 15:17:08 -03:00 committed by GitHub
parent 3122c92ced
commit 45e04b0901
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View file

@ -53,6 +53,18 @@ impl<'b> MultiEraRedeemer<'b> {
}
}
pub fn into_conway_deprecated(&self) -> Option<conway::Redeemer> {
match self {
Self::AlonzoCompatible(_) => None,
Self::Conway(x, y) => Some(conway::Redeemer {
tag: x.tag,
index: x.index,
data: y.data.clone(),
ex_units: y.ex_units,
}),
}
}
pub fn from_alonzo_compatible(redeemer: &'b alonzo::Redeemer) -> Self {
Self::AlonzoCompatible(Box::new(Cow::Borrowed(redeemer)))
}

View file

@ -199,9 +199,9 @@ impl<'b> MultiEraTx<'b> {
/// Return inputs as expected for processing
///
/// To process inputs we need a set (no duplicated) and lexicographical
/// order (hash#idx). This function will take the raw inputs and apply the
/// aforementioned cleanup changes.
/// To process inputs we need a set (no duplicates) and lexicographical
/// order (hash#idx). This function will take the raw inputs and apply a
/// sort following these requirements.
pub fn inputs_sorted_set(&self) -> Vec<MultiEraInput> {
let mut raw = self.inputs();
raw.sort_by_key(|x| x.lexicographical_key());

View file

@ -57,7 +57,7 @@ pub type DRepVotingThresholds = conway::DRepVotingThresholds;
use crate::{Era, MultiEraUpdate};
impl<'b> MultiEraUpdate<'b> {
pub fn decode_for_era(era: Era, cbor: &'b [u8]) -> Result<Self, minicbor::decode::Error> {
pub fn decode_for_era(era: Era, cbor: &[u8]) -> Result<Self, minicbor::decode::Error> {
match era {
Era::Byron => {
let (epoch, up) = minicbor::decode(cbor)?;