Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
restore FFI set_scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
finiteprods committed Feb 3, 2021
1 parent d9f36df commit 5976e3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions rust/xaynet-mobile/src/ffi/settings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::os::raw::{c_int, c_uint};
use std::os::raw::{c_double, c_int};

use ffi_support::{ByteBuffer, FfiStr};
use xaynet_core::crypto::{ByteObject, PublicSigningKey, SecretSigningKey, SigningKeyPair};
Expand Down Expand Up @@ -82,12 +82,11 @@ pub unsafe extern "C" fn xaynet_ffi_settings_new() -> *mut Settings {
#[no_mangle]
pub unsafe extern "C" fn xaynet_ffi_settings_set_scalar(
settings: *mut Settings,
numer: c_uint,
denom: c_uint,
scalar: c_double,
) -> c_int {
match unsafe { settings.as_mut() } {
Some(settings) => {
settings.set_scalar(numer, denom);
settings.set_scalar(scalar);
OK
}
None => ERR_NULLPTR,
Expand Down
9 changes: 6 additions & 3 deletions rust/xaynet-mobile/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use std::convert::TryInto;
use thiserror::Error;
use xaynet_core::{crypto::SigningKeyPair, mask::Scalar};
use xaynet_core::{
crypto::SigningKeyPair,
mask::{FromPrimitive, Scalar},
};
use xaynet_sdk::settings::{MaxMessageSize, PetSettings};

/// A participant settings
Expand Down Expand Up @@ -43,8 +46,8 @@ impl Settings {
}

/// Set the scalar to use for masking
pub fn set_scalar(&mut self, numer: u32, denom: u32) {
self.scalar = Scalar::new(numer, denom)
pub fn set_scalar(&mut self, scalar: f64) {
self.scalar = Scalar::from_primitive(scalar).unwrap() // FIXME better to avoid f64
}

/// Set the Xaynet coordinator address
Expand Down

0 comments on commit 5976e3a

Please sign in to comment.