|
|
@ -37,6 +37,7 @@ type PublicStakingService struct { |
|
|
|
// TEMP SOLUTION to rpc node spamming issue
|
|
|
|
// TEMP SOLUTION to rpc node spamming issue
|
|
|
|
limiterGetAllValidatorInformation *rate.Limiter |
|
|
|
limiterGetAllValidatorInformation *rate.Limiter |
|
|
|
limiterGetAllDelegationInformation *rate.Limiter |
|
|
|
limiterGetAllDelegationInformation *rate.Limiter |
|
|
|
|
|
|
|
limiterGetDelegationsByValidator *rate.Limiter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewPublicStakingAPI creates a new API for the RPC interface
|
|
|
|
// NewPublicStakingAPI creates a new API for the RPC interface
|
|
|
@ -51,6 +52,7 @@ func NewPublicStakingAPI(hmy *hmy.Harmony, version Version) rpc.API { |
|
|
|
validatorInfoCache: viCache, |
|
|
|
validatorInfoCache: viCache, |
|
|
|
limiterGetAllValidatorInformation: rate.NewLimiter(1, 3), |
|
|
|
limiterGetAllValidatorInformation: rate.NewLimiter(1, 3), |
|
|
|
limiterGetAllDelegationInformation: rate.NewLimiter(1, 3), |
|
|
|
limiterGetAllDelegationInformation: rate.NewLimiter(1, 3), |
|
|
|
|
|
|
|
limiterGetDelegationsByValidator: rate.NewLimiter(5, 20), |
|
|
|
}, |
|
|
|
}, |
|
|
|
Public: true, |
|
|
|
Public: true, |
|
|
|
} |
|
|
|
} |
|
|
@ -542,7 +544,7 @@ func (s *PublicStakingService) GetAllDelegationInformation( |
|
|
|
// Fetch all delegations
|
|
|
|
// Fetch all delegations
|
|
|
|
validators := make([][]StructuredResponse, validatorsNum) |
|
|
|
validators := make([][]StructuredResponse, validatorsNum) |
|
|
|
for i := start; i < start+validatorsNum; i++ { |
|
|
|
for i := start; i < start+validatorsNum; i++ { |
|
|
|
validators[i-start], err = s.GetDelegationsByValidator(ctx, addresses[i].String()) |
|
|
|
validators[i-start], err = s.getDelegationByValidatorHelper(addresses[i].String()) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
DoMetricRPCQueryInfo(GetAllDelegationInformation, FailedNumber) |
|
|
|
DoMetricRPCQueryInfo(GetAllDelegationInformation, FailedNumber) |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
@ -687,6 +689,15 @@ func (s *PublicStakingService) GetDelegationsByValidator( |
|
|
|
return nil, ErrNotBeaconShard |
|
|
|
return nil, ErrNotBeaconShard |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := s.wait(s.limiterGetDelegationsByValidator, ctx) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
DoMetricRPCQueryInfo(GetDelegationsByValidator, FailedNumber) |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return s.getDelegationByValidatorHelper(address) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (s *PublicStakingService) getDelegationByValidatorHelper(address string) ([]StructuredResponse, error) { |
|
|
|
// Fetch delegations
|
|
|
|
// Fetch delegations
|
|
|
|
validatorAddress, err := internal_common.ParseAddr(address) |
|
|
|
validatorAddress, err := internal_common.ParseAddr(address) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|