Running goimports gofmt, gosimple, uncovert to fix lint issues

This commit is contained in:
Jitendra Bhurat 2020-06-03 11:48:38 -04:00
parent 26421dd4df
commit 164d32caf2
11 changed files with 33 additions and 34 deletions

View File

@ -17,7 +17,6 @@
package core
import (
"github.com/ethereum/go-ethereum/consensus/istanbul"
"math/big"
"reflect"
"sync"
@ -25,6 +24,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/istanbul"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
@ -327,19 +327,19 @@ func TestProcessBacklog(t *testing.T) {
roundChangePayload, _ := Encode(roundChange)
msgs := []*message{
&message{
{
Code: msgPreprepare,
Msg: prepreparePayload,
},
&message{
{
Code: msgPrepare,
Msg: subjectPayload,
},
&message{
{
Code: msgCommit,
Msg: subjectPayload,
},
&message{
{
Code: msgRoundChange,
Msg: roundChangePayload,
},

View File

@ -204,7 +204,7 @@ OUTER:
committedSeals := v0.committedMsgs[0].committedSeals
for _, validator := range r0.valSet.List() {
for _, seal := range committedSeals {
if bytes.Compare(validator.Address().Bytes(), seal[:common.AddressLength]) == 0 {
if bytes.Equal(validator.Address().Bytes(), seal[:common.AddressLength]) {
signedCount++
break
}

View File

@ -361,7 +361,7 @@ func validateMsgSignature(messages map[common.Address]*message, validateFn func(
if err != nil {
return err
}
if bytes.Compare(signerAdd.Bytes(), msg.Address.Bytes()) != 0 {
if !bytes.Equal(signerAdd.Bytes(), msg.Address.Bytes()) {
return errInvalidSigner
}
}

View File

@ -43,4 +43,4 @@ var (
errInvalidSigner = errors.New("message not signed by the sender")
// errInvalidPreparedBlock is returned when prepared block is not validated in round change messages
errInvalidPreparedBlock = errors.New("invalid prepared block in round change messages")
)
)

View File

@ -124,4 +124,4 @@ func TestHandleMsg(t *testing.T) {
if err := r0.handleMsg([]byte{1}); err == nil {
t.Errorf("error mismatch: have %v, want nil", err)
}
}
}

View File

@ -347,4 +347,4 @@ func TestVerifyPrepare(t *testing.T) {
}
}
}
}
}

View File

@ -142,9 +142,9 @@ OUTER:
curView := r0.currentView()
preprepare := &Preprepare{
View: curView,
Proposal: test.expectedRequest,
RCMessages: newMessageSet(r0.valSet),
View: curView,
Proposal: test.expectedRequest,
RCMessages: newMessageSet(r0.valSet),
PreparedMessages: newMessageSet(r0.valSet),
}

View File

@ -118,7 +118,7 @@ func (c *core) handleRoundChange(msg *message, src istanbul.Validator) error {
num := c.roundChangeSet.higherRoundMessages(cv.Round)
currentRoundMessages := c.roundChangeSet.getRCMessagesForGivenRound(cv.Round)
if num == int(c.valSet.F()+1) {
if num == c.valSet.F()+1 {
newRound := c.roundChangeSet.getMinRoundChange(cv.Round)
logger.Trace("Starting new Round", "round", newRound)
c.startNewRound(newRound)

View File

@ -29,28 +29,28 @@ import (
// newRoundState creates a new roundState instance with the given view and validatorSet
func newRoundState(view *View, validatorSet istanbul.ValidatorSet, preprepare *Preprepare, pendingRequest *Request, hasBadProposal func(hash common.Hash) bool) *roundState {
return &roundState{
round: view.Round,
sequence: view.Sequence,
Preprepare: preprepare,
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
mu: new(sync.RWMutex),
pendingRequest: pendingRequest,
hasBadProposal: hasBadProposal,
preprepareSent: big.NewInt(0),
round: view.Round,
sequence: view.Sequence,
Preprepare: preprepare,
Prepares: newMessageSet(validatorSet),
Commits: newMessageSet(validatorSet),
mu: new(sync.RWMutex),
pendingRequest: pendingRequest,
hasBadProposal: hasBadProposal,
preprepareSent: big.NewInt(0),
}
}
// roundState stores the consensus state
type roundState struct {
round *big.Int
sequence *big.Int
Preprepare *Preprepare
Prepares *messageSet
Commits *messageSet
pendingRequest *Request
preparedRound *big.Int
preparedBlock istanbul.Proposal
round *big.Int
sequence *big.Int
Preprepare *Preprepare
Prepares *messageSet
Commits *messageSet
pendingRequest *Request
preparedRound *big.Int
preparedBlock istanbul.Proposal
mu *sync.RWMutex
hasBadProposal func(hash common.Hash) bool

View File

@ -18,13 +18,13 @@ package core
import (
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/core/rawdb"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/istanbul"
"github.com/ethereum/go-ethereum/consensus/istanbul/validator"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"

View File

@ -85,7 +85,6 @@ const (
msgPrepare
msgCommit
msgRoundChange
msgAll
)
type message struct {
@ -145,7 +144,7 @@ func (m *message) FromPayload(b []byte, validateFn func([]byte, []byte) (common.
if err != nil {
return err
}
if bytes.Compare(signerAdd.Bytes(), m.Address.Bytes()) != 0 {
if !bytes.Equal(signerAdd.Bytes(), m.Address.Bytes()) {
return errInvalidSigner
}
}