node icon indicating copy to clipboard operation
node copied to clipboard

Unable to use floats to check rates are below threshold

Open ltfschoen opened this issue 5 years ago • 1 comments

In file DataHighway-com/node/packages/mining/mining-speed-boosts/rates/token-mining/src/lib.rs. How to use floats to check these values aren't too large without gettging error

the trait std::str::FromStr is not implemented for <T as Trait>::MiningSpeedBoostRatesTokenMiningMaxToken

This will require changing relevant types from u64 to f64 and u32 to f32 and getting it to compile.


            // if token_token_mxc > "1.2".parse().unwrap() || token_token_iota > "1.2".parse().unwrap() || token_token_dot > "1.2".parse().unwrap() || token_max_token > "1.6".parse().unwrap() || token_max_loyalty > "1.2".parse().unwrap() {
            //   debug::info!("Token rate cannot be this large");
              
            //   return Ok(());
            // }

ltfschoen avatar Feb 12 '20 07:02 ltfschoen

Use fixed point arithmetic instead of floats. See https://substrate.dev/recipes/fixed-point.html

ltfschoen avatar Feb 27 '21 15:02 ltfschoen