|
8 | 8 | "errors" |
9 | 9 | "fmt" |
10 | 10 | "net/http" |
| 11 | + "os" |
| 12 | + "strings" |
11 | 13 | "time" |
12 | 14 |
|
13 | 15 | stdmath "math" |
|
78 | 80 | errMissingPrivateKey = errors.New("argument 'privateKey' not given") |
79 | 81 | errStartAfterEndTime = errors.New("start time must be before end time") |
80 | 82 | errStartTimeInThePast = errors.New("start time in the past") |
| 83 | + |
| 84 | + completeGetValidators = false |
81 | 85 | ) |
82 | 86 |
|
| 87 | +func init() { |
| 88 | + // if COMPLETE_GET_VALIDATORS is set to true, the getCurrentValidators API will return delegators |
| 89 | + // for every node. Otherwise, it will only return delegators if a single nodeID is provided. |
| 90 | + completeGetValidators = strings.ToUpper(os.Getenv("COMPLETE_GET_VALIDATORS")) == "TRUE" |
| 91 | +} |
| 92 | + |
83 | 93 | // Service defines the API calls that can be made to the platform chain |
84 | 94 | type Service struct { |
85 | 95 | vm *VM |
@@ -881,8 +891,8 @@ func (s *Service) GetCurrentValidators(_ *http.Request, args *GetCurrentValidato |
881 | 891 | case txs.PrimaryNetworkDelegatorCurrentPriority, txs.SubnetPermissionlessDelegatorCurrentPriority: |
882 | 892 | var rewardOwner *platformapi.Owner |
883 | 893 | // If we are handling multiple nodeIDs, we don't return the |
884 | | - // delegator information. |
885 | | - if numNodeIDs == 1 { |
| 894 | + // delegator information unless completeGetValidators is true. |
| 895 | + if numNodeIDs == 1 || completeGetValidators { |
886 | 896 | attr, err := s.loadStakerTxAttributes(currentStaker.TxID) |
887 | 897 | if err != nil { |
888 | 898 | return err |
@@ -941,8 +951,8 @@ func (s *Service) GetCurrentValidators(_ *http.Request, args *GetCurrentValidato |
941 | 951 | vdr.DelegatorCount = &delegatorCount |
942 | 952 | vdr.DelegatorWeight = &delegatorWeight |
943 | 953 |
|
944 | | - if numNodeIDs == 1 { |
945 | | - // queried a specific validator, load all of its delegators |
| 954 | + if numNodeIDs == 1 || completeGetValidators { |
| 955 | + // queried a specific validator or completeGetValidators is true, load all of its delegators |
946 | 956 | vdr.Delegators = &delegators |
947 | 957 | } |
948 | 958 | reply.Validators[i] = vdr |
|
0 commit comments