File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed
chain-impl-mockchain/src/vote Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,10 @@ pub struct Args {
37
37
/// cross reference official results
38
38
#[ clap( short, long) ]
39
39
official_results : Option < String > ,
40
- /// Quadratic scaling
40
+ /// Gamma value for Quadratic scaling
41
41
#[ clap( short, long) ]
42
42
gamma : Option < String > ,
43
- /// Quadratic scaling
43
+ /// Rounding precision for arithmetic
44
44
#[ clap( short, long) ]
45
45
precision : Option < String > ,
46
46
}
@@ -103,8 +103,8 @@ fn main() -> Result<(), Box<dyn Error>> {
103
103
let shares_and_results = extract_decryption_shares_and_results ( all_fragments) ;
104
104
105
105
if let Some ( gamma) = args. gamma {
106
- const SCALE_FACTOR : & str = "QUADRATIC_VOTING_SCALING_FACTOR " ;
107
- std:: env:: set_var ( SCALE_FACTOR , gamma) ;
106
+ const GAMMA : & str = "QUADRATIC_VOTING_GAMMA " ;
107
+ std:: env:: set_var ( GAMMA , gamma) ;
108
108
}
109
109
110
110
if let Some ( precision) = args. precision {
Original file line number Diff line number Diff line change @@ -173,14 +173,14 @@ impl TallyResult {
173
173
} else {
174
174
let index = choice. as_byte ( ) as usize ;
175
175
176
- const SCALE_FACTOR : & str = "QUADRATIC_VOTING_SCALING_FACTOR " ;
176
+ const GAMMA : & str = "QUADRATIC_VOTING_GAMMA " ;
177
177
const PRECISION : & str = "QUADRATIC_VOTING_PRECISION" ;
178
178
179
- let scaling_factor = env:: var ( SCALE_FACTOR ) . unwrap_or ( 1 . to_string ( ) ) ;
179
+ let gamma = env:: var ( GAMMA ) . unwrap_or ( 1 . to_string ( ) ) ;
180
180
let precision =
181
181
i64:: from_str ( & env:: var ( PRECISION ) . unwrap_or ( 1 . to_string ( ) ) ) . unwrap_or ( 1 ) ;
182
182
183
- let gamma = BigDecimal :: from_str ( & scaling_factor ) . unwrap_or ( BigDecimal :: from ( 1 ) ) ;
183
+ let gamma = BigDecimal :: from_str ( & gamma ) . unwrap_or ( BigDecimal :: from ( 1 ) ) ;
184
184
let stake = BigDecimal :: from ( weight. 0 ) ;
185
185
186
186
let weight = ( gamma * stake)
Original file line number Diff line number Diff line change @@ -165,13 +165,13 @@ impl EncryptedTally {
165
165
assert_eq ! ( ballot. vote( ) . len( ) , self . r. len( ) ) ;
166
166
assert_eq ! ( ballot. fingerprint( ) , & self . fingerprint) ;
167
167
168
- const SCALE_FACTOR : & str = "QUADRATIC_VOTING_SCALING_FACTOR " ;
168
+ const GAMMA : & str = "QUADRATIC_VOTING_GAMMA " ;
169
169
const PRECISION : & str = "QUADRATIC_VOTING_PRECISION" ;
170
170
171
- let scaling_factor = env:: var ( SCALE_FACTOR ) . unwrap_or ( 1 . to_string ( ) ) ;
171
+ let gamma = env:: var ( GAMMA ) . unwrap_or ( 1 . to_string ( ) ) ;
172
172
let precision = i64:: from_str ( & env:: var ( PRECISION ) . unwrap_or ( 1 . to_string ( ) ) ) . unwrap_or ( 1 ) ;
173
173
174
- let gamma = BigDecimal :: from_str ( & scaling_factor ) . unwrap_or ( BigDecimal :: from ( 1 ) ) ;
174
+ let gamma = BigDecimal :: from_str ( & gamma ) . unwrap_or ( BigDecimal :: from ( 1 ) ) ;
175
175
let stake = BigDecimal :: from ( weight) ;
176
176
177
177
let weight = ( gamma * stake) . round ( precision) . to_u64 ( ) . unwrap_or ( weight) ;
You can’t perform that action at this time.
0 commit comments