18
18
errMinimumHeight = errors .New ("unexpectedly called GetMinimumHeight" )
19
19
errCurrentHeight = errors .New ("unexpectedly called GetCurrentHeight" )
20
20
errSubnetID = errors .New ("unexpectedly called GetSubnetID" )
21
+ errGetAllValidatorSets = errors .New ("unexpectedly called GetAllValidatorSets" )
21
22
errGetValidatorSet = errors .New ("unexpectedly called GetValidatorSet" )
22
23
errGetCurrentValidatorSet = errors .New ("unexpectedly called GetCurrentValidatorSet" )
23
24
)
@@ -30,12 +31,14 @@ type State struct {
30
31
CantGetMinimumHeight ,
31
32
CantGetCurrentHeight ,
32
33
CantGetSubnetID ,
33
- CantGetValidatorSet bool
34
+ CantGetAllValidatorSets bool
35
+ CantGetValidatorSet bool
34
36
CantGetCurrentValidatorSet bool
35
37
36
38
GetMinimumHeightF func (ctx context.Context ) (uint64 , error )
37
39
GetCurrentHeightF func (ctx context.Context ) (uint64 , error )
38
40
GetSubnetIDF func (ctx context.Context , chainID ids.ID ) (ids.ID , error )
41
+ GetAllValidatorSetsF func (ctx context.Context , height uint64 ) (map [ids.ID ]map [ids.NodeID ]* validators.GetValidatorOutput , error )
39
42
GetValidatorSetF func (ctx context.Context , height uint64 , subnetID ids.ID ) (map [ids.NodeID ]* validators.GetValidatorOutput , error )
40
43
GetCurrentValidatorSetF func (ctx context.Context , subnetID ids.ID ) (map [ids.ID ]* validators.GetCurrentValidatorOutput , uint64 , error )
41
44
}
@@ -70,6 +73,19 @@ func (vm *State) GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error
70
73
return ids .Empty , errSubnetID
71
74
}
72
75
76
+ func (vm * State ) GetAllValidatorSets (
77
+ ctx context.Context ,
78
+ height uint64 ,
79
+ ) (map [ids.ID ]map [ids.NodeID ]* validators.GetValidatorOutput , error ) {
80
+ if vm .GetAllValidatorSetsF != nil {
81
+ return vm .GetAllValidatorSetsF (ctx , height )
82
+ }
83
+ if vm .CantGetAllValidatorSets && vm .T != nil {
84
+ require .FailNow (vm .T , errGetAllValidatorSets .Error ())
85
+ }
86
+ return nil , errGetAllValidatorSets
87
+ }
88
+
73
89
func (vm * State ) GetValidatorSet (
74
90
ctx context.Context ,
75
91
height uint64 ,
@@ -78,7 +94,7 @@ func (vm *State) GetValidatorSet(
78
94
if vm .GetValidatorSetF != nil {
79
95
return vm .GetValidatorSetF (ctx , height , subnetID )
80
96
}
81
- if vm .CantGetValidatorSet && vm .T != nil {
97
+ if vm .CantGetAllValidatorSets && vm .T != nil {
82
98
require .FailNow (vm .T , errGetValidatorSet .Error ())
83
99
}
84
100
return nil , errGetValidatorSet
0 commit comments