@@ -236,7 +236,6 @@ impl<'a> Delegation<'a> {
236
236
237
237
#[ derive( Clone , Copy , Debug , Eq , Ord , PartialEq , PartialOrd , RlpDecodable , RlpEncodable ) ]
238
238
pub struct Validator {
239
- weight : StakeQuantity ,
240
239
delegation : StakeQuantity ,
241
240
deposit : Deposit ,
242
241
pubkey : Public ,
@@ -245,7 +244,6 @@ pub struct Validator {
245
244
impl Validator {
246
245
pub fn new_for_test ( delegation : StakeQuantity , deposit : Deposit , pubkey : Public ) -> Self {
247
246
Self {
248
- weight : delegation,
249
247
delegation,
250
248
deposit,
251
249
pubkey,
@@ -254,17 +252,12 @@ impl Validator {
254
252
255
253
fn new ( delegation : StakeQuantity , deposit : Deposit , pubkey : Public ) -> Self {
256
254
Self {
257
- weight : delegation,
258
255
delegation,
259
256
deposit,
260
257
pubkey,
261
258
}
262
259
}
263
260
264
- fn reset ( & mut self ) {
265
- self . weight = self . delegation ;
266
- }
267
-
268
261
pub fn pubkey ( & self ) -> & Public {
269
262
& self . pubkey
270
263
}
@@ -345,28 +338,6 @@ impl Validators {
345
338
Ok ( ( ) )
346
339
}
347
340
348
- pub fn update_weight ( & mut self , block_author : & Address ) {
349
- let min_delegation = self . min_delegation ( ) ;
350
- for Validator {
351
- weight,
352
- pubkey,
353
- ..
354
- } in self . 0 . iter_mut ( ) . rev ( )
355
- {
356
- if public_to_address ( pubkey) == * block_author {
357
- // block author
358
- * weight = weight. saturating_sub ( min_delegation) ;
359
- break
360
- }
361
- // neglecting validators
362
- * weight = weight. saturating_sub ( min_delegation * 2 ) ;
363
- }
364
- if self . 0 . iter ( ) . all ( |validator| validator. weight == 0 ) {
365
- self . 0 . iter_mut ( ) . for_each ( Validator :: reset) ;
366
- }
367
- self . 0 . sort_unstable ( ) ;
368
- }
369
-
370
341
pub fn remove ( & mut self , target : & Address ) {
371
342
self . 0 . retain (
372
343
|Validator {
@@ -379,10 +350,6 @@ impl Validators {
379
350
pub fn delegation ( & self , pubkey : & Public ) -> Option < StakeQuantity > {
380
351
self . 0 . iter ( ) . find ( |validator| validator. pubkey == * pubkey) . map ( |& validator| validator. delegation )
381
352
}
382
-
383
- fn min_delegation ( & self ) -> StakeQuantity {
384
- self . 0 . iter ( ) . map ( |& validator| validator. delegation ) . min ( ) . expect ( "There must be at least one validators" )
385
- }
386
353
}
387
354
388
355
impl Deref for Validators {
@@ -1758,7 +1725,6 @@ mod tests {
1758
1725
pubkey : * pubkey,
1759
1726
deposit : 0 ,
1760
1727
delegation : 0 ,
1761
- weight : 0 ,
1762
1728
} )
1763
1729
. collect ( ) ,
1764
1730
) ;
0 commit comments