fix: favor Babbage over Conway for tx decoding (#389)

This commit is contained in:
Santiago Carmuega 2024-01-28 16:26:23 -03:00 committed by GitHub
parent 700d109d31
commit 7f0e022f1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -64,13 +64,17 @@ impl<'b> MultiEraTx<'b> {
/// Try decode a transaction via every era's encoding format, starting with
/// the most recent and returning on first success, or None if none are
/// successful
///
/// NOTE: Until Conway is officially released, this method favors Babbage
/// decoding over Conway decoding. This means that we'll attempt to
/// decode using Babbage first even if Conway is newer.
pub fn decode(cbor: &'b [u8]) -> Result<Self, Error> {
if let Ok(tx) = minicbor::decode(cbor) {
return Ok(MultiEraTx::Conway(Box::new(Cow::Owned(tx))));
return Ok(MultiEraTx::Babbage(Box::new(Cow::Owned(tx))));
}
if let Ok(tx) = minicbor::decode(cbor) {
return Ok(MultiEraTx::Babbage(Box::new(Cow::Owned(tx))));
return Ok(MultiEraTx::Conway(Box::new(Cow::Owned(tx))));
}
if let Ok(tx) = minicbor::decode(cbor) {