Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
chore: support conversion from tonic Response to Beacon Block
Browse files Browse the repository at this point in the history
  • Loading branch information
suchapalaver committed Oct 7, 2024
1 parent e746c57 commit b4f5393
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -545,6 +548,16 @@ pub mod beacon {
}
}

impl TryFrom<Response> for Block {
type Error = ProtosError;

fn try_from(response: Response) -> Result<Self, Self::Error> {
let any = response.block.ok_or(ProtosError::NullBlock)?;
let block = Block::decode(any.value.as_ref())?;
Ok(block)
}
}

impl<E: EthSpec> TryFrom<SyncAggregate> for types::SyncAggregate<E> {
type Error = ProtosError;

Expand Down

0 comments on commit b4f5393

Please sign in to comment.