Skip to content

Commit

Permalink
Protobuf conversion functions for Fog Ledger Router
Browse files Browse the repository at this point in the history
  • Loading branch information
awygle committed Dec 14, 2022
1 parent 4b03032 commit 5c806e9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion fog/api/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//
// Contains helper methods that enable conversions for Fog Api types.

use crate::{fog_common, ingest_common, view::MultiViewStoreQueryRequest};
use crate::{
fog_common, ingest_common, ledger::MultiKeyImageStoreRequest, view::MultiViewStoreQueryRequest,
};
use mc_api::ConversionError;
use mc_attest_api::attest;
use mc_attest_enclave_api::{EnclaveMessage, NonceSession};
Expand Down Expand Up @@ -30,6 +32,25 @@ impl From<Vec<attest::NonceMessage>> for MultiViewStoreQueryRequest {
}
}

impl From<Vec<EnclaveMessage<NonceSession>>> for MultiKeyImageStoreRequest {
fn from(enclave_messages: Vec<EnclaveMessage<NonceSession>>) -> MultiKeyImageStoreRequest {
enclave_messages
.into_iter()
.map(|enclave_message| enclave_message.into())
.collect::<Vec<attest::NonceMessage>>()
.into()
}
}

impl From<Vec<attest::NonceMessage>> for MultiKeyImageStoreRequest {
fn from(attested_query_messages: Vec<attest::NonceMessage>) -> MultiKeyImageStoreRequest {
let mut multi_key_image_store_request = MultiKeyImageStoreRequest::new();
multi_key_image_store_request.set_queries(attested_query_messages.into());

multi_key_image_store_request
}
}

impl From<&common::BlockRange> for fog_common::BlockRange {
fn from(common_block_range: &common::BlockRange) -> fog_common::BlockRange {
let mut proto_block_range = fog_common::BlockRange::new();
Expand Down

0 comments on commit 5c806e9

Please sign in to comment.