Skip to content

Commit

Permalink
feat(traverse): introduce small QoL improvements (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Dec 29, 2024
1 parent 3122c92 commit 45e04b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions pallas-traverse/src/redeemers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand Down
6 changes: 3 additions & 3 deletions pallas-traverse/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion pallas-traverse/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 45e04b0

Please sign in to comment.