@@ -3,18 +3,7 @@ use crate::{
3
3
value:: Value ,
4
4
vote:: { Choice , Options } ,
5
5
} ;
6
-
7
6
use chain_vote:: EncryptedTally ;
8
- use core:: cmp:: Ordering ;
9
- use num:: FromPrimitive ;
10
-
11
- use num:: Rational32 ;
12
- use rug:: Integer ;
13
- use rug:: { float:: Round , ops:: Pow , Float , Rational } ;
14
-
15
- use std:: str:: FromStr ;
16
-
17
- use std:: env;
18
7
use std:: fmt;
19
8
use thiserror:: Error ;
20
9
@@ -177,39 +166,7 @@ impl TallyResult {
177
166
} else {
178
167
let index = choice. as_byte ( ) as usize ;
179
168
180
- const GAMMA : & str = "QUADRATIC_VOTING_GAMMA" ;
181
- const PRECISION : & str = "QUADRATIC_VOTING_PRECISION" ;
182
-
183
- // Apply quadratic scaling if gamma value specified in env var. Else gamma is 1 and has no effect.
184
- let mut gamma = f64:: from_str ( & env:: var ( GAMMA ) . unwrap_or ( 1.0 . to_string ( ) ) ) . unwrap ( ) ;
185
- // Gamma must be between 0 and 1, anything else is treated as bad input; defaulting gamma to 1.
186
- if gamma < 0.0 || gamma > 1.0 {
187
- gamma = 1.0 ;
188
- }
189
-
190
- let precision =
191
- u32:: from_str ( & env:: var ( PRECISION ) . unwrap_or ( 1 . to_string ( ) ) ) . unwrap_or ( 1 ) ;
192
-
193
- let gamma = Rational32 :: from_f64 ( gamma) . unwrap_or ( Rational32 :: from_integer ( 1 ) ) ;
194
- let denom = gamma. denom ( ) ;
195
- let numer = gamma. numer ( ) ;
196
-
197
- let stake = Float :: with_val ( precision, weight. 0 ) ;
198
-
199
- // rational = gamma in rational form i.e fraction
200
- // 0.5 = 1/2
201
- let gamma = Float :: with_val ( precision, & Rational :: from ( ( * numer, * denom) ) ) ;
202
-
203
- let stake_with_gamma_scaling = stake. clone ( ) . pow ( & gamma) ;
204
-
205
- let weight = stake_with_gamma_scaling
206
- . to_integer_round ( Round :: Nearest )
207
- . unwrap_or ( ( Integer :: from ( weight. 0 ) , Ordering :: Less ) )
208
- . 0
209
- . to_u64 ( )
210
- . unwrap_or ( weight. 0 ) ;
211
-
212
- self . results [ index] = self . results [ index] . saturating_add ( Weight ( weight) ) ;
169
+ self . results [ index] = self . results [ index] . saturating_add ( weight) ;
213
170
214
171
Ok ( ( ) )
215
172
}
0 commit comments