@@ -68,25 +68,27 @@ func (f *BlockFetcher) Commit(ctx context.Context, height *int64) (*types.Commit
68
68
return res .Commit , nil
69
69
}
70
70
71
- // maxValidators is a maximum amount of validators
72
- // Should be in sync with network params and paging provided by Client
73
- const maxValidators = 100
74
-
75
71
// ValidatorSet queries Core for the ValidatorSet from the
76
72
// block at the given height.
77
73
func (f * BlockFetcher ) ValidatorSet (ctx context.Context , height * int64 ) (* types.ValidatorSet , error ) {
78
- // FIXME: The ugliness of passing pointers for integers in this case can't be explained with words
79
- maxVals := maxValidators
80
- res , err := f .client .Validators (ctx , height , nil , & maxVals )
81
- if err != nil {
82
- return nil , err
83
- }
74
+ var perPage = 100
75
+
76
+ vals , total := make ([]* types.Validator , 0 ), - 1
77
+ for page := 1 ; len (vals ) != total ; page ++ {
78
+ res , err := f .client .Validators (ctx , height , & page , & perPage )
79
+ if err != nil {
80
+ return nil , err
81
+ }
82
+
83
+ if res != nil && len (res .Validators ) == 0 {
84
+ return nil , fmt .Errorf ("core/fetcher: validators not found" )
85
+ }
84
86
85
- if res != nil && res .Validators == nil {
86
- return nil , fmt . Errorf ( "core/fetcher: validators not found" )
87
+ total = res .Total
88
+ vals = append ( vals , res . Validators ... )
87
89
}
88
90
89
- return types .NewValidatorSet (res . Validators ), nil
91
+ return types .NewValidatorSet (vals ), nil
90
92
}
91
93
92
94
// SubscribeNewBlockEvent subscribes to new block events from Core, returning
0 commit comments