Skip to content

Commit

Permalink
shielded-pool(fmd): restore pb conversion traits
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Jan 26, 2024
1 parent 63781f2 commit 95ca083
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions crates/core/component/shielded-pool/src/fmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,29 @@ pub struct Parameters {
pub as_of_block_height: u64,
}

// TODO(erwan): re-enable on second pass
// impl DomainType for FmdParameters {
// type Proto = pb::FmdParameters;
// }
//
// impl TryFrom<pb::FmdParameters> for FmdParameters {
// type Error = anyhow::Error;
//
// fn try_from(msg: pb::FmdParameters) -> Result<Self, Self::Error> {
// Ok(FmdParameters {
// precision_bits: msg.precision_bits.try_into()?,
// as_of_block_height: msg.as_of_block_height,
// })
// }
// }
//
// impl From<FmdParameters> for pb::FmdParameters {
// fn from(params: FmdParameters) -> Self {
// pb::FmdParameters {
// precision_bits: u32::from(params.precision_bits),
// as_of_block_height: params.as_of_block_height,
// }
// }
// }
impl DomainType for FmdParameters {
type Proto = pb::FmdParameters;
}

impl TryFrom<pb::FmdParameters> for FmdParameters {
type Error = anyhow::Error;

fn try_from(msg: pb::FmdParameters) -> Result<Self, Self::Error> {
Ok(FmdParameters {
precision_bits: msg.precision_bits.try_into()?,
as_of_block_height: msg.as_of_block_height,
})
}
}

impl From<FmdParameters> for pb::FmdParameters {
fn from(params: FmdParameters) -> Self {
pb::FmdParameters {
precision_bits: u32::from(params.precision_bits),
as_of_block_height: params.as_of_block_height,
}
}
}

impl Default for Parameters {
fn default() -> Self {
Expand Down

0 comments on commit 95ca083

Please sign in to comment.