feat(traverse): introduce small QoL improvements (#567)
This commit is contained in:
parent
3122c92ced
commit
45e04b0901
3 changed files with 16 additions and 4 deletions
|
|
@ -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 {
|
pub fn from_alonzo_compatible(redeemer: &'b alonzo::Redeemer) -> Self {
|
||||||
Self::AlonzoCompatible(Box::new(Cow::Borrowed(redeemer)))
|
Self::AlonzoCompatible(Box::new(Cow::Borrowed(redeemer)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,9 +199,9 @@ impl<'b> MultiEraTx<'b> {
|
||||||
|
|
||||||
/// Return inputs as expected for processing
|
/// Return inputs as expected for processing
|
||||||
///
|
///
|
||||||
/// To process inputs we need a set (no duplicated) and lexicographical
|
/// To process inputs we need a set (no duplicates) and lexicographical
|
||||||
/// order (hash#idx). This function will take the raw inputs and apply the
|
/// order (hash#idx). This function will take the raw inputs and apply a
|
||||||
/// aforementioned cleanup changes.
|
/// sort following these requirements.
|
||||||
pub fn inputs_sorted_set(&self) -> Vec<MultiEraInput> {
|
pub fn inputs_sorted_set(&self) -> Vec<MultiEraInput> {
|
||||||
let mut raw = self.inputs();
|
let mut raw = self.inputs();
|
||||||
raw.sort_by_key(|x| x.lexicographical_key());
|
raw.sort_by_key(|x| x.lexicographical_key());
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ pub type DRepVotingThresholds = conway::DRepVotingThresholds;
|
||||||
use crate::{Era, MultiEraUpdate};
|
use crate::{Era, MultiEraUpdate};
|
||||||
|
|
||||||
impl<'b> MultiEraUpdate<'b> {
|
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 {
|
match era {
|
||||||
Era::Byron => {
|
Era::Byron => {
|
||||||
let (epoch, up) = minicbor::decode(cbor)?;
|
let (epoch, up) = minicbor::decode(cbor)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue