mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Replace Empty Slice Literals with Nil Slices (#13093)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
9c938d354d
commit
76fec1799e
@ -769,7 +769,7 @@ func TestFinalizedDeposits_ReturnsTrieCorrectly(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
ctrs := []*ethpb.DepositContainer{}
|
||||
var ctrs []*ethpb.DepositContainer
|
||||
for i := 0; i < 2000; i++ {
|
||||
ctrs = append(ctrs, generateCtr(uint64(10+(i/2)), int64(i)))
|
||||
}
|
||||
|
@ -622,9 +622,9 @@ func (s *Service) ReconstructFullBellatrixBlockBatch(
|
||||
if len(blindedBlocks) == 0 {
|
||||
return []interfaces.SignedBeaconBlock{}, nil
|
||||
}
|
||||
executionHashes := []common.Hash{}
|
||||
validExecPayloads := []int{}
|
||||
zeroExecPayloads := []int{}
|
||||
var executionHashes []common.Hash
|
||||
var validExecPayloads []int
|
||||
var zeroExecPayloads []int
|
||||
for i, b := range blindedBlocks {
|
||||
if err := blocks.BeaconBlockIsNil(b); err != nil {
|
||||
return nil, errors.Wrap(err, "cannot reconstruct bellatrix block from nil data")
|
||||
|
@ -461,7 +461,7 @@ func convertToUdpMultiAddr(node *enode.Node) ([]ma.Multiaddr, error) {
|
||||
}
|
||||
|
||||
func peerIdsFromMultiAddrs(addrs []ma.Multiaddr) []peer.ID {
|
||||
peers := []peer.ID{}
|
||||
var peers []peer.ID
|
||||
for _, a := range addrs {
|
||||
info, err := peer.AddrInfoFromP2pAddr(a)
|
||||
if err != nil {
|
||||
|
@ -118,7 +118,7 @@ func (s *Store) SetTrustedPeers(peers []peer.ID) {
|
||||
// GetTrustedPeers gets our desired trusted peer ids.
|
||||
// Important: it is assumed that store mutex is locked when calling this method.
|
||||
func (s *Store) GetTrustedPeers() []peer.ID {
|
||||
peers := []peer.ID{}
|
||||
var peers []peer.ID
|
||||
for p := range s.trustedPeers {
|
||||
peers = append(peers, p)
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ func TestPrunePeers_TrustedPeers(t *testing.T) {
|
||||
createPeer(t, p, nil, network.DirInbound, peerdata.PeerConnectionState(ethpb.ConnectionState_CONNECTED))
|
||||
}
|
||||
|
||||
trustedPeers := []peer.ID{}
|
||||
var trustedPeers []peer.ID
|
||||
// Set up bad scores for inbound peers.
|
||||
inboundPeers := p.InboundConnected()
|
||||
for i, pid := range inboundPeers {
|
||||
|
@ -86,7 +86,7 @@ func (s *Server) AddTrustedPeer(w http.ResponseWriter, r *http.Request) {
|
||||
s.PeersFetcher.Peers().Add(nil, info.ID, info.Addrs[0], direction)
|
||||
}
|
||||
|
||||
peers := []peer.ID{}
|
||||
var peers []peer.ID
|
||||
peers = append(peers, info.ID)
|
||||
s.PeersFetcher.Peers().SetTrustedPeers(peers)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@ -112,7 +112,7 @@ func (s *Server) RemoveTrustedPeer(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
peers := []peer.ID{}
|
||||
var peers []peer.ID
|
||||
peers = append(peers, peerId)
|
||||
s.PeersFetcher.Peers().DeleteTrustedPeers(peers)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var Commands = []*cli.Command{}
|
||||
var Commands []*cli.Command
|
||||
|
||||
func init() {
|
||||
Commands = append(Commands, checkpoint.Commands...)
|
||||
|
@ -47,7 +47,7 @@ func walletCreate(c *cli.Context) error {
|
||||
|
||||
// ConstructCLIManagerOpts prompts the user for wallet creation input.
|
||||
func ConstructCLIManagerOpts(cliCtx *cli.Context, keymanagerKind keymanager.Kind) ([]accounts.Option, error) {
|
||||
cliOpts := []accounts.Option{}
|
||||
var cliOpts []accounts.Option
|
||||
// Get wallet dir and check that no wallet exists at the location.
|
||||
walletDir, err := userprompt.InputDirectory(cliCtx, userprompt.WalletDirPromptText, flags.WalletDirFlag)
|
||||
if err != nil {
|
||||
|
@ -70,4 +70,4 @@ var deprecatedFlags = []cli.Flag{
|
||||
|
||||
// deprecatedBeaconFlags contains flags that are still used by other components
|
||||
// and therefore cannot be added to deprecatedFlags
|
||||
var deprecatedBeaconFlags = []cli.Flag{}
|
||||
var deprecatedBeaconFlags []cli.Flag
|
||||
|
@ -94,7 +94,7 @@ func TestPublicKey_Aggregate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPublicKey_Aggregation_NoCorruption(t *testing.T) {
|
||||
pubkeys := []common.PublicKey{}
|
||||
var pubkeys []common.PublicKey
|
||||
for i := 0; i < 100; i++ {
|
||||
priv, err := blst.RandKey()
|
||||
require.NoError(t, err)
|
||||
@ -102,7 +102,7 @@ func TestPublicKey_Aggregation_NoCorruption(t *testing.T) {
|
||||
pubkeys = append(pubkeys, pubkey)
|
||||
}
|
||||
|
||||
compressedKeys := [][]byte{}
|
||||
var compressedKeys [][]byte
|
||||
// Fill up the cache
|
||||
for _, pkey := range pubkeys {
|
||||
_, err := blst.PublicKeyFromBytes(pkey.Marshal())
|
||||
|
@ -20,7 +20,7 @@ var versionToString = map[int]string{
|
||||
|
||||
// stringToVersion and allVersions are populated in init()
|
||||
var stringToVersion = map[string]int{}
|
||||
var allVersions = []int{}
|
||||
var allVersions []int
|
||||
|
||||
// ErrUnrecognizedVersionName means a string does not match the list of canonical version names.
|
||||
var ErrUnrecognizedVersionName = errors.New("version name doesn't map to a known value in the enum")
|
||||
|
@ -153,7 +153,7 @@ func processesDepositsInBlocks(ec *e2etypes.EvaluationContext, conns ...*grpc.Cl
|
||||
observed[k] = v + d.Data.Amount
|
||||
}
|
||||
}
|
||||
mismatches := []string{}
|
||||
var mismatches []string
|
||||
for k, ev := range expected {
|
||||
ov := observed[k]
|
||||
if ev != ov {
|
||||
@ -361,7 +361,7 @@ func proposeVoluntaryExit(ec *e2etypes.EvaluationContext, conns ...*grpc.ClientC
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get state")
|
||||
}
|
||||
execIndices := []int{}
|
||||
var execIndices []int
|
||||
err = st.ReadFromEveryValidator(func(idx int, val state.ReadOnlyValidator) error {
|
||||
if val.WithdrawalCredentials()[0] == params.BeaconConfig().ETH1AddressWithdrawalPrefixByte {
|
||||
execIndices = append(execIndices, idx)
|
||||
|
@ -244,7 +244,7 @@ func (p *Builder) isBuilderCall(req *http.Request) bool {
|
||||
}
|
||||
|
||||
func (p *Builder) registerValidators(w http.ResponseWriter, req *http.Request) {
|
||||
registrations := []shared.SignedValidatorRegistration{}
|
||||
var registrations []shared.SignedValidatorRegistration
|
||||
if err := json.NewDecoder(req.Body).Decode(®istrations); err != nil {
|
||||
http.Error(w, "invalid request", http.StatusBadRequest)
|
||||
return
|
||||
|
@ -60,7 +60,7 @@ func (c *waitForActivationClient) Recv() (*ethpb.ValidatorActivationResponse, er
|
||||
// Contains all keys in targetPubKeys but not in retrievedPubKeys
|
||||
var missingPubKeys [][]byte
|
||||
|
||||
statuses := []*ethpb.ValidatorActivationResponse_Status{}
|
||||
var statuses []*ethpb.ValidatorActivationResponse_Status
|
||||
|
||||
for index, publicKey := range c.ValidatorActivationRequest.PublicKeys {
|
||||
stringPubKey := hexutil.Encode(publicKey)
|
||||
|
@ -55,7 +55,7 @@ func (c *beaconApiValidatorClient) getValidatorsStatusResponse(ctx context.Conte
|
||||
stringRetrievedPubKeys := make(map[string]struct{})
|
||||
|
||||
// Contains all keys in targetPubKeys but not in retrievedPubKeys
|
||||
missingPubKeys := [][]byte{}
|
||||
var missingPubKeys [][]byte
|
||||
|
||||
totalLen := len(inPubKeys) + len(inIndexes)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user