Skip to content

Commit

Permalink
Removes redundant type conversions (#6041)
Browse files Browse the repository at this point in the history
* removes redundant type conversions
* remove redundant type in struct decl
* removes redundant parens
* Merge refs/heads/master into redundant-type-conversions
  • Loading branch information
farazdagi committed May 29, 2020
1 parent 0eaf0cf commit a0bf8cb
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/info.go
Expand Up @@ -54,7 +54,7 @@ func (s *Service) TreeHandler(w http.ResponseWriter, _ *http.Request) {
slot := strconv.Itoa(int(nodes[i].Slot))
weight := strconv.Itoa(int(nodes[i].Weight / 1e9)) // Convert unit Gwei to unit ETH.
votes := strconv.Itoa(int(nodes[i].Weight / 1e9 / avgBalance))
index := strconv.Itoa(int(i))
index := strconv.Itoa(i)
g := nodes[i].Graffiti[:]
graffiti := hex.EncodeToString(g[:8])
label := "slot: " + slot + "\n votes: " + votes + "\n weight: " + weight + "\n graffiti: " + graffiti
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/core/blocks/block_operations.go
Expand Up @@ -856,7 +856,7 @@ func ProcessPreGenesisDeposit(
validator.ActivationEligibilityEpoch = 0
validator.ActivationEpoch = 0
}
if err := beaconState.UpdateValidatorAtIndex(uint64(index), validator); err != nil {
if err := beaconState.UpdateValidatorAtIndex(index, validator); err != nil {
return nil, err
}
return beaconState, nil
Expand Down Expand Up @@ -952,7 +952,7 @@ func ProcessDeposit(
return nil, err
}
} else {
if err := helpers.IncreaseBalance(beaconState, uint64(index), amount); err != nil {
if err := helpers.IncreaseBalance(beaconState, index, amount); err != nil {
return nil, err
}
}
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/rpc/beacon/committees_test.go
Expand Up @@ -36,7 +36,7 @@ func TestServer_ListBeaconCommittees_CurrentEpoch(t *testing.T) {
headState := setupActiveValidators(t, db, numValidators)

m := &mock.ChainService{
Genesis: roughtime.Now().Add(time.Duration(-1*int64((headState.Slot()*params.BeaconConfig().SecondsPerSlot))) * time.Second),
Genesis: roughtime.Now().Add(time.Duration(-1*int64(headState.Slot()*params.BeaconConfig().SecondsPerSlot)) * time.Second),
}
bs := &Server{
HeadFetcher: m,
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestServer_ListBeaconCommittees_PreviousEpoch(t *testing.T) {

m := &mock.ChainService{
State: headState,
Genesis: roughtime.Now().Add(time.Duration(-1*int64((headState.Slot()*params.BeaconConfig().SecondsPerSlot))) * time.Second),
Genesis: roughtime.Now().Add(time.Duration(-1*int64(headState.Slot()*params.BeaconConfig().SecondsPerSlot)) * time.Second),
}
bs := &Server{
HeadFetcher: m,
Expand Down Expand Up @@ -269,7 +269,7 @@ func TestRetrieveCommitteesForRoot(t *testing.T) {
headState := setupActiveValidators(t, db, numValidators)

m := &mock.ChainService{
Genesis: roughtime.Now().Add(time.Duration(-1*int64((headState.Slot()*params.BeaconConfig().SecondsPerSlot))) * time.Second),
Genesis: roughtime.Now().Add(time.Duration(-1*int64(headState.Slot()*params.BeaconConfig().SecondsPerSlot)) * time.Second),
}
bs := &Server{
HeadFetcher: m,
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/rpc/validator/assignments_test.go
Expand Up @@ -32,7 +32,7 @@ import (
// pubKey is a helper to generate a well-formed public key.
func pubKey(i uint64) []byte {
pubKey := make([]byte, params.BeaconConfig().BLSPubkeyLength)
binary.LittleEndian.PutUint64(pubKey, uint64(i))
binary.LittleEndian.PutUint64(pubKey, i)
return pubKey
}
func TestGetDuties_NextEpoch_CantFindValidatorIdx(t *testing.T) {
Expand Down
16 changes: 8 additions & 8 deletions beacon-chain/rpc/validator/status_test.go
Expand Up @@ -976,18 +976,18 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
}

want := []*ethpb.ValidatorStatusResponse{
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_ACTIVE,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_ACTIVE,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_DEPOSITED,
DepositInclusionSlot: 53,
ActivationEpoch: 18446744073709551615,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_DEPOSITED,
},
}
Expand Down Expand Up @@ -1066,16 +1066,16 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) {
}

want := []*ethpb.ValidatorStatusResponse{
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_ACTIVE,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_ACTIVE,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_DEPOSITED,
},
&ethpb.ValidatorStatusResponse{
{
Status: ethpb.ValidatorStatus_SLASHING,
},
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/sync/rpc_beacon_blocks_by_range.go
Expand Up @@ -97,7 +97,7 @@ func (r *Service) beaconBlocksByRangeRPCHandler(ctx context.Context, msg interfa

// Recalculate start and end slots for the next batch to be returned to the remote peer.
startSlot = endSlot + m.Step
endSlot = startSlot + (m.Step * (uint64(allowedBlocksPerSecond) - 1))
endSlot = startSlot + (m.Step * (allowedBlocksPerSecond - 1))
if endSlot > endReqSlot {
endSlot = endReqSlot
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/sync/rpc_status_test.go
Expand Up @@ -296,7 +296,7 @@ func TestHandshakeHandlers_Roundtrip(t *testing.T) {
}
})

pcl = protocol.ID("/eth2/beacon_chain/req/ping/1/ssz")
pcl = "/eth2/beacon_chain/req/ping/1/ssz"
var wg2 sync.WaitGroup
wg2.Add(1)
p2.Host.SetStreamHandler(pcl, func(stream network.Stream) {
Expand Down
4 changes: 2 additions & 2 deletions shared/cmd/helpers.go
Expand Up @@ -53,15 +53,15 @@ func EnterPassword(confirmPassword bool, pr PasswordReader) (string, error) {
if err != nil {
return "", errors.Wrap(err, "could not read account password")
}
text := string(bytePassword)
text := bytePassword
passphrase = strings.Replace(text, "\n", "", -1)
if confirmPassword {
log.Info("Please re-enter your password:")
bytePassword, err := pr.ReadPassword()
if err != nil {
return "", errors.Wrap(err, "could not read account password")
}
text := string(bytePassword)
text := bytePassword
confirmedPass := strings.Replace(text, "\n", "", -1)
if passphrase != confirmedPass {
log.Info("Passwords did not match, please try again")
Expand Down

0 comments on commit a0bf8cb

Please sign in to comment.