-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add REST implementation for GetSyncSubcommitteeIndex #11971
add REST implementation for GetSyncSubcommitteeIndex #11971
Conversation
var indices []primitives.CommitteeIndex | ||
for _, idx := range syncDuty.ValidatorSyncCommitteeIndices { | ||
syncCommIdx, err := strconv.ParseUint(idx, 10, 64) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to parse validator sync committee index") | ||
} | ||
|
||
indices = append(indices, primitives.CommitteeIndex(syncCommIdx)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var indices []primitives.CommitteeIndex | |
for _, idx := range syncDuty.ValidatorSyncCommitteeIndices { | |
syncCommIdx, err := strconv.ParseUint(idx, 10, 64) | |
if err != nil { | |
return nil, errors.Wrap(err, "failed to parse validator sync committee index") | |
} | |
indices = append(indices, primitives.CommitteeIndex(syncCommIdx)) | |
} | |
indices := make([]primitives.CommitteeIndex, len(syncDuty.ValidatorSyncCommitteeIndices)) | |
for i, idx := range syncDuty.ValidatorSyncCommitteeIndices { | |
syncCommIdx, err := strconv.ParseUint(idx, 10, 64) | |
if err != nil { | |
return nil, errors.Wrap(err, "failed to parse validator sync committee index") | |
} | |
indices[i] = primitives.CommitteeIndex(syncCommIdx) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nalepae !
Slice initialisation with make is recommended when the length of slice is constant or already known. In our case it length of indices
depends on length syncDuty.ValidatorSyncCommitteeIndices
slice. If syncDuty.ValidatorSyncCommitteeIndices
slice is empty/nil then it doesn't make sense to pre-allocate indices slice. This makes zero value of slice useful, also recommended by Rob Pike: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=385s
|
||
// TODO: Implement me | ||
panic("beaconApiValidatorClient.GetSyncCommitteeContribution is not implemented. To use a fallback client, create this validator with NewBeaconApiValidatorClientWithFallback instead.") | ||
return c.getSyncCommitteeContribution(ctx, in) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
Co-authored-by: Radosław Kapka <radek@prysmaticlabs.com>
What type of PR is this?
Feature
Related issue
#11580
What does this PR do? Why is it needed?
It adds REST API implementation for
GetSyncSubcommitteeIndex
.