11use catalyst_toolbox:: rewards:: voters:: calc_voter_rewards;
2- use catalyst_toolbox:: rewards:: { Rewards , Threshold } ;
2+ use catalyst_toolbox:: rewards:: { Rewards , Threshold , VoteCount } ;
33use catalyst_toolbox:: utils:: assert_are_close;
44
55use color_eyre:: eyre:: eyre;
66use color_eyre:: { Report , Result } ;
77use jcli_lib:: block:: open_output;
88use jcli_lib:: jcli_lib:: block:: Common ;
99
10+ use snapshot_lib:: registration:: MainnetRewardAddress ;
11+ use snapshot_lib:: SnapshotInfo ;
1012use structopt:: StructOpt ;
11- use vit_servicing_station_lib:: db:: models:: proposals:: FullProposalInfo ;
1213
1314use std:: collections:: BTreeMap ;
1415use std:: path:: { Path , PathBuf } ;
@@ -35,7 +36,7 @@ pub struct VotersRewards {
3536
3637 /// Number of global votes required to be able to receive voter rewards
3738 #[ structopt( long, default_value) ]
38- vote_threshold : usize ,
39+ vote_threshold : u64 ,
3940
4041 /// Path to a json-encoded map from challenge id to an optional required threshold
4142 /// per-challenge in order to receive rewards.
@@ -77,7 +78,6 @@ impl VotersRewards {
7778 proposals,
7879 } = self ;
7980
80- <<<<<<< HEAD
8181 voter_rewards (
8282 common
8383 . output_file
@@ -88,42 +88,6 @@ impl VotersRewards {
8888 vote_threshold,
8989 total_rewards,
9090 )
91- =======
92- let proposals = serde_json:: from_reader:: < _ , Vec < FullProposalInfo > > (
93- jcli_lib:: utils:: io:: open_file_read( & Some ( proposals) ) ?,
94- ) ?;
95-
96- let vote_count = super :: extract_individual_votes(
97- proposals. clone( ) ,
98- serde_json:: from_reader:: < _ , HashMap < Identifier , Vec < AccountVotes > > > (
99- jcli_lib:: utils:: io:: open_file_read( & Some ( votes_count_path) ) ?,
100- ) ?,
101- ) ?;
102-
103- let snapshot: Vec < SnapshotInfo > = serde_json:: from_reader(
104- jcli_lib:: utils:: io:: open_file_read( & Some ( snapshot_info_path) ) ?,
105- ) ?;
106-
107- let additional_thresholds: HashMap < i32 , usize > = if let Some ( file) = per_challenge_threshold
108- {
109- serde_json : : from_reader( jcli_lib:: utils:: io:: open_file_read( & Some ( file) ) ?) ?
110- } else {
111- HashMap :: new( )
112- } ;
113-
114- let results = calc_voter_rewards(
115- vote_count,
116- snapshot,
117- Threshold :: new( vote_threshold, additional_thresholds, proposals) ?,
118- Rewards :: from( total_rewards) ,
119- ) ?;
120-
121- let actual_rewards = results. values( ) . sum :: < Rewards > ( ) ;
122- assert_are_close( actual_rewards, Rewards :: from( total_rewards) ) ;
123-
124- write_rewards_results( common, & results) ?;
125- Ok ( ( ) )
126- >>>>>>> main
12791 }
12892}
12993
@@ -143,8 +107,12 @@ pub fn voter_rewards(
143107
144108 let results = calc_voter_rewards (
145109 vote_count,
146- vote_threshold,
147110 snapshot,
111+ Threshold :: new (
112+ vote_threshold as usize ,
113+ Default :: default ( ) ,
114+ Default :: default ( ) ,
115+ ) ?,
148116 Rewards :: from ( total_rewards) ,
149117 ) ?;
150118
0 commit comments