@@ -106,9 +106,11 @@ pub struct Edge<AccountId> {
106106pub  type  PhragmenAssignment < AccountId >  = ( AccountId ,  ExtendedBalance ) ; 
107107
108108/// Final result of the phragmen election. 
109+ #[ cfg_attr( feature = "std" ,  derive( Debug ) ) ]  
109110pub  struct  PhragmenResult < AccountId >  { 
110- 	/// Just winners. 
111- pub  winners :  Vec < AccountId > , 
111+ 	/// Just winners zipped with their approval stake. Note that the approval stake is merely the 
112+ /// sub of their received stake and could be used for very basic sorting and approval voting. 
113+ pub  winners :  Vec < ( AccountId ,  ExtendedBalance ) > , 
112114	/// Individual assignments. for each tuple, the first elements is a voter and the second 
113115/// is the list of candidates that it supports. 
114116pub  assignments :  Vec < ( AccountId ,  Vec < PhragmenAssignment < AccountId > > ) > 
@@ -166,7 +168,7 @@ pub fn elect<AccountId, Balance, FS, C>(
166168		<C  as  Convert < Balance ,  u64 > >:: convert ( b)  as  ExtendedBalance ; 
167169
168170	// return structures 
169- 	let  mut  elected_candidates:  Vec < AccountId > ; 
171+ 	let  mut  elected_candidates:  Vec < ( AccountId ,   ExtendedBalance ) > ; 
170172	let  mut  assigned:  Vec < ( AccountId ,  Vec < PhragmenAssignment < AccountId > > ) > ; 
171173
172174	// used to cache and access candidates index. 
@@ -282,7 +284,7 @@ pub fn elect<AccountId, Balance, FS, C>(
282284				} 
283285			} 
284286
285- 			elected_candidates. push ( winner. who . clone ( ) ) ; 
287+ 			elected_candidates. push ( ( winner. who . clone ( ) ,  winner . approval_stake ) ) ; 
286288		}  else  { 
287289			break 
288290		} 
@@ -292,8 +294,8 @@ pub fn elect<AccountId, Balance, FS, C>(
292294	for  n in  & mut  voters { 
293295		let  mut  assignment = ( n. who . clone ( ) ,  vec ! [ ] ) ; 
294296		for  e in  & mut  n. edges  { 
295- 			if  let  Some ( c)  = elected_candidates. iter ( ) . cloned ( ) . find ( |c | * c == e. who )  { 
296- 				if  c != n. who  { 
297+ 			if  let  Some ( c)  = elected_candidates. iter ( ) . cloned ( ) . find ( |( c ,  _ ) | * c == e. who )  { 
298+ 				if  c. 0  != n. who  { 
297299					let  ratio = { 
298300						// Full support. No need to calculate. 
299301						if  * n. load  == * e. load  {  ACCURACY  } 
0 commit comments