prysmaticlabs / prysm

Types of function parameters can be combined CRT-A0017
Style
Major
10 days ago4 years old
func(ctx context.Context, err error, blockRoot [32]byte, parentRoot [32]byte) error could be replaced with func(ctx context.Context, err error, blockRoot, parentRoot [32]byte) error
679	}
680}
681
682func (s *Service) handleInvalidExecutionError(ctx context.Context, err error, blockRoot [32]byte, parentRoot [32]byte) error {683	if IsInvalidBlock(err) && InvalidBlockLVH(err) != [32]byte{} {
684		return s.pruneInvalidBlock(ctx, blockRoot, parentRoot, InvalidBlockLVH(err))
685	}
func(ctx context.Context, method string, path string, body io.Reader, opts ...reqOption) (res []byte, err error) could be replaced with func(ctx context.Context, method, path string, body io.Reader, opts ...reqOption) (res []byte, err error)
137type reqOption func(*http.Request)
138
139// do is a generic, opinionated request function to reduce boilerplate amongst the methods in this package api/client/builder.
140func (c *Client) do(ctx context.Context, method string, path string, body io.Reader, opts ...reqOption) (res []byte, err error) {141	ctx, span := trace.StartSpan(ctx, "builder.client.do")
142	defer func() {
143		tracing.AnnotateError(span, err)
func(blk interfaces.SignedBeaconBlock, blobs [][]byte, kzgProofs [][]byte) ([]*ethpb.BlobSidecar, error) could be replaced with func(blk interfaces.SignedBeaconBlock, blobs, kzgProofs [][]byte) ([]*ethpb.BlobSidecar, error)
57}
58
59// BuildBlobSidecars given a block, builds the blob sidecars for the block.
60func BuildBlobSidecars(blk interfaces.SignedBeaconBlock, blobs [][]byte, kzgProofs [][]byte) ([]*ethpb.BlobSidecar, error) {61	if blk.Version() < version.Deneb {
62		return nil, nil // No blobs before deneb.
63	}
func(ctx context.Context, orphanedRoot [32]byte, newHeadRoot [32]byte) error could be replaced with func(ctx context.Context, orphanedRoot, newHeadRoot [32]byte) error
376
377// This saves the Attestations and BLSToExecChanges between `orphanedRoot` and the common ancestor root that is derived using `newHeadRoot`.
378// It also filters out the attestations that is one epoch older as a defense so invalid attestations don't flow into the attestation pool.
379func (s *Service) saveOrphanedOperations(ctx context.Context, orphanedRoot [32]byte, newHeadRoot [32]byte) error {380	commonAncestorRoot, _, err := s.cfg.ForkChoiceStore.CommonAncestor(ctx, newHeadRoot, orphanedRoot)
381	switch {
382	// Exit early if there's no common ancestor and root doesn't exist, there would be nothing to save.
func(ctx context.Context, currentBlockNum uint64, latestFollowHeight uint64, batchSize uint64, additiveFactor uint64, logCount uint64, headersMap map[uint64]*types.HeaderInfo) (uint64, uint64, error) could be replaced with func(ctx context.Context, currentBlockNum, latestFollowHeight, batchSize, additiveFactor, logCount uint64, headersMap map[uint64]*types.HeaderInfo) (uint64, uint64, error)
358	return nil
359}
360
361func (s *Service) processBlockInBatch(ctx context.Context, currentBlockNum uint64, latestFollowHeight uint64, batchSize uint64, additiveFactor uint64, logCount uint64, headersMap map[uint64]*types.HeaderInfo) (uint64, uint64, error) {362	// Batch request the desired headers and store them in a
363	// map for quick access.
364	requestHeaders := func(startBlk uint64, endBlk uint64) error {