diff --git a/.gitignore b/.gitignore index d744ce2..f0b91a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target Cargo.lock + +.DS_Store diff --git a/src/lib.rs b/src/lib.rs index e8c3924..637591d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -198,7 +198,10 @@ pub mod firehose { pub mod beacon { pub mod r#type { pub mod v1 { - use crate::{firehose::v2::SingleBlockResponse, ProtosError}; + use crate::{ + firehose::v2::{Response, SingleBlockResponse}, + ProtosError, + }; use primitive_types::{H256, U256}; use prost::Message; use ssz_types::{length::Fixed, Bitfield, FixedVector}; @@ -545,6 +548,16 @@ pub mod beacon { } } + impl TryFrom for Block { + type Error = ProtosError; + + fn try_from(response: Response) -> Result { + let any = response.block.ok_or(ProtosError::NullBlock)?; + let block = Block::decode(any.value.as_ref())?; + Ok(block) + } + } + impl TryFrom for types::SyncAggregate { type Error = ProtosError;