From 4a55a856f2bf1014799a2847159b2a41cc7a3300 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 13 Nov 2024 08:13:15 -0500 Subject: [PATCH] allow streamable deserialization with extra bytes --- crates/chia-traits/src/streamable.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/chia-traits/src/streamable.rs b/crates/chia-traits/src/streamable.rs index 6be2dab34..a18c0ba93 100644 --- a/crates/chia-traits/src/streamable.rs +++ b/crates/chia-traits/src/streamable.rs @@ -66,6 +66,14 @@ pub trait Streamable { Err(Error::InputTooLarge) } } + fn from_bytes_ignore_extra_bytes(bytes: &[u8]) -> Result + where + Self: Sized, + { + let mut cursor = Cursor::new(bytes); + let ret = Self::parse::(&mut cursor)?; + Ok(ret) + } fn hash(&self) -> [u8; 32] { let mut ctx = Sha256::new(); self.update_digest(&mut ctx);