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

Commit

Permalink
Merge pull request #20 from semiotic-ai/joseph/tru-327-support-conver…
Browse files Browse the repository at this point in the history
…sion-from-grpc-response-to-beacon-block-in-sf

Support conversion from grpc response to beacon block
  • Loading branch information
suchapalaver authored Oct 7, 2024
2 parents 9b5784d + b4f5393 commit 992fa91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target

Cargo.lock

.DS_Store
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 992fa91

Please sign in to comment.