Skip to content

Commit 262ae3f

Browse files
committed
consensus/core: fix lint failed
1 parent 28fa7d2 commit 262ae3f

File tree

12 files changed

+30
-43
lines changed

12 files changed

+30
-43
lines changed

consensus/istanbul/backend/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (sb *backend) Verify(proposal istanbul.Proposal) (time.Duration, error) {
239239

240240
// Sign implements istanbul.Backend.Sign
241241
func (sb *backend) Sign(data []byte) ([]byte, error) {
242-
hashData := crypto.Keccak256([]byte(data))
242+
hashData := crypto.Keccak256(data)
243243
return crypto.Sign(hashData, sb.privateKey)
244244
}
245245

consensus/istanbul/backend/backend_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,8 @@ func TestCommit(t *testing.T) {
148148
for _, test := range testCases {
149149
expBlock := test.expectedBlock()
150150
go func() {
151-
select {
152-
case result := <-backend.commitCh:
153-
commitCh <- result
154-
return
155-
}
151+
result := <-backend.commitCh
152+
commitCh <- result
156153
}()
157154

158155
backend.proposedBlockHash = expBlock.Hash()

consensus/istanbul/backend/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var (
8181
// errEmptyCommittedSeals is returned if the field of committed seals is zero.
8282
errEmptyCommittedSeals = errors.New("zero committed seals")
8383
// errMismatchTxhashes is returned if the TxHash in header is mismatch.
84-
errMismatchTxhashes = errors.New("mismatch transcations hashes")
84+
errMismatchTxhashes = errors.New("mismatch transactions hashes")
8585
)
8686
var (
8787
defaultDifficulty = big.NewInt(1)

consensus/istanbul/backend/engine_test.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,12 @@ func TestSealStopChannel(t *testing.T) {
163163
stop := make(chan struct{}, 1)
164164
eventSub := engine.EventMux().Subscribe(istanbul.RequestEvent{})
165165
eventLoop := func() {
166-
select {
167-
case ev := <-eventSub.Chan():
168-
_, ok := ev.Data.(istanbul.RequestEvent)
169-
if !ok {
170-
t.Errorf("unexpected event comes: %v", reflect.TypeOf(ev.Data))
171-
}
172-
stop <- struct{}{}
166+
ev := <-eventSub.Chan()
167+
_, ok := ev.Data.(istanbul.RequestEvent)
168+
if !ok {
169+
t.Errorf("unexpected event comes: %v", reflect.TypeOf(ev.Data))
173170
}
171+
stop <- struct{}{}
174172
eventSub.Unsubscribe()
175173
}
176174
go eventLoop()
@@ -189,14 +187,12 @@ func TestSealCommittedOtherHash(t *testing.T) {
189187
otherBlock := makeBlockWithoutSeal(chain, engine, block)
190188
eventSub := engine.EventMux().Subscribe(istanbul.RequestEvent{})
191189
eventLoop := func() {
192-
select {
193-
case ev := <-eventSub.Chan():
194-
_, ok := ev.Data.(istanbul.RequestEvent)
195-
if !ok {
196-
t.Errorf("unexpected event comes: %v", reflect.TypeOf(ev.Data))
197-
}
198-
engine.Commit(otherBlock, [][]byte{})
190+
ev := <-eventSub.Chan()
191+
_, ok := ev.Data.(istanbul.RequestEvent)
192+
if !ok {
193+
t.Errorf("unexpected event comes: %v", reflect.TypeOf(ev.Data))
199194
}
195+
engine.Commit(otherBlock, [][]byte{})
200196
eventSub.Unsubscribe()
201197
}
202198
go eventLoop()
@@ -208,10 +204,8 @@ func TestSealCommittedOtherHash(t *testing.T) {
208204

209205
const timeoutDura = 2 * time.Second
210206
timeout := time.NewTimer(timeoutDura)
211-
select {
212-
case <-timeout.C:
213-
// wait 2 seconds to ensure we cannot get any blocks from Istanbul
214-
}
207+
<-timeout.C
208+
// wait 2 seconds to ensure we cannot get any blocks from Istanbul
215209
}
216210

217211
func TestSealCommitted(t *testing.T) {

consensus/istanbul/backend/snapshot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
207207
// Tally up the new vote from the validator
208208
var authorize bool
209209
switch {
210-
case bytes.Compare(header.Nonce[:], nonceAuthVote) == 0:
210+
case bytes.Equal(header.Nonce[:], nonceAuthVote):
211211
authorize = true
212-
case bytes.Compare(header.Nonce[:], nonceDropVote) == 0:
212+
case bytes.Equal(header.Nonce[:], nonceDropVote):
213213
authorize = false
214214
default:
215215
return nil, errInvalidVote

consensus/istanbul/backend/snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func TestSaveAndLoad(t *testing.T) {
417417
},
418418
},
419419
Tally: map[common.Address]Tally{
420-
common.StringToAddress("1234567893"): Tally{
420+
common.StringToAddress("1234567893"): {
421421
Authorize: false,
422422
Votes: 20,
423423
},

consensus/istanbul/core/backlog_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,19 @@ func TestProcessBacklog(t *testing.T) {
299299
subjectPayload, _ := Encode(subject)
300300

301301
msgs := []*message{
302-
&message{
302+
{
303303
Code: msgPreprepare,
304304
Msg: prepreparePayload,
305305
},
306-
&message{
306+
{
307307
Code: msgPrepare,
308308
Msg: subjectPayload,
309309
},
310-
&message{
310+
{
311311
Code: msgCommit,
312312
Msg: subjectPayload,
313313
},
314-
&message{
314+
{
315315
Code: msgRoundChange,
316316
Msg: subjectPayload,
317317
},

consensus/istanbul/core/commit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ OUTER:
210210
committedSeals := v0.committedMsgs[0].committedSeals
211211
for _, validator := range r0.valSet.List() {
212212
for _, seal := range committedSeals {
213-
if bytes.Compare(validator.Address().Bytes(), seal[:common.AddressLength]) == 0 {
213+
if bytes.Equal(validator.Address().Bytes(), seal[:common.AddressLength]) {
214214
signedCount++
215215
break
216216
}

consensus/istanbul/core/core_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,12 @@ func TestNewRequest(t *testing.T) {
5757
request1 := makeBlock(1)
5858
sys.backends[0].NewRequest(request1)
5959

60-
select {
61-
case <-time.After(1 * time.Second):
62-
}
60+
<-time.After(1 * time.Second)
6361

6462
request2 := makeBlock(2)
6563
sys.backends[0].NewRequest(request2)
6664

67-
select {
68-
case <-time.After(1 * time.Second):
69-
}
65+
<-time.After(1 * time.Second)
7066

7167
for _, backend := range sys.backends {
7268
if len(backend.committedMsgs) != 2 {

consensus/istanbul/core/roundchange.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ func (c *core) handleRoundChange(msg *message, src istanbul.Validator) error {
9393
// Once we received f+1 ROUND CHANGE messages, those messages form a weak certificate.
9494
// If our round number is smaller than the certificate's round number, we would
9595
// try to catch up the round number.
96-
if c.waitingForRoundChange && num == int(c.valSet.F()+1) {
96+
if c.waitingForRoundChange && num == c.valSet.F()+1 {
9797
if cv.Round.Cmp(roundView.Round) < 0 {
9898
c.sendRoundChange(roundView.Round)
9999
}
100100
return nil
101-
} else if num == int(2*c.valSet.F()+1) && (c.waitingForRoundChange || cv.Round.Cmp(roundView.Round) < 0) {
101+
} else if num == 2*c.valSet.F()+1 && (c.waitingForRoundChange || cv.Round.Cmp(roundView.Round) < 0) {
102102
// We've received 2f+1 ROUND CHANGE messages, start a new round immediately.
103103
c.startNewRound(roundView.Round)
104104
return nil

0 commit comments

Comments
 (0)