Skip to content

Commit 8f06b79

Browse files
committed
eth: fix megacheck warnings
1 parent 9710798 commit 8f06b79

7 files changed

Lines changed: 17 additions & 40 deletions

File tree

‎eth/api.go‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -465,26 +465,6 @@ func (api *PrivateDebugAPI) traceBlock(block *types.Block, logConfig *vm.LogConf
465465
return true, structLogger.StructLogs(), nil
466466
}
467467

468-
// callmsg is the message type used for call transitions.
469-
type callmsg struct {
470-
addr common.Address
471-
to *common.Address
472-
gas, gasPrice *big.Int
473-
value *big.Int
474-
data []byte
475-
}
476-
477-
// accessor boilerplate to implement core.Message
478-
func (m callmsg) From() (common.Address, error) { return m.addr, nil }
479-
func (m callmsg) FromFrontier() (common.Address, error) { return m.addr, nil }
480-
func (m callmsg) Nonce() uint64 { return 0 }
481-
func (m callmsg) CheckNonce() bool { return false }
482-
func (m callmsg) To() *common.Address { return m.to }
483-
func (m callmsg) GasPrice() *big.Int { return m.gasPrice }
484-
func (m callmsg) Gas() *big.Int { return m.gas }
485-
func (m callmsg) Value() *big.Int { return m.value }
486-
func (m callmsg) Data() []byte { return m.data }
487-
488468
// formatError formats a Go error into either an empty string or the data content
489469
// of the error itself.
490470
func formatError(err error) string {

‎eth/downloader/downloader_test.go‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ func (dl *downloadTester) newSlowPeer(id string, version int, hashes []common.Ha
403403
dl.lock.Lock()
404404
defer dl.lock.Unlock()
405405

406-
var err error
407-
err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl, id, delay})
406+
var err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl, id, delay})
408407
if err == nil {
409408
// Assign the owned hashes, headers and blocks to the peer (deep copy)
410409
dl.peerHashes[id] = make([]common.Hash, len(hashes))
@@ -1381,7 +1380,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
13811380
go func() {
13821381
defer pending.Done()
13831382
if err := tester.sync("peer-half", nil, mode); err != nil {
1384-
t.Fatalf("failed to synchronise blocks: %v", err)
1383+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
13851384
}
13861385
}()
13871386
<-starting
@@ -1398,7 +1397,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) {
13981397
go func() {
13991398
defer pending.Done()
14001399
if err := tester.sync("peer-full", nil, mode); err != nil {
1401-
t.Fatalf("failed to synchronise blocks: %v", err)
1400+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
14021401
}
14031402
}()
14041403
<-starting
@@ -1454,7 +1453,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14541453
go func() {
14551454
defer pending.Done()
14561455
if err := tester.sync("fork A", nil, mode); err != nil {
1457-
t.Fatalf("failed to synchronise blocks: %v", err)
1456+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
14581457
}
14591458
}()
14601459
<-starting
@@ -1474,7 +1473,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
14741473
go func() {
14751474
defer pending.Done()
14761475
if err := tester.sync("fork B", nil, mode); err != nil {
1477-
t.Fatalf("failed to synchronise blocks: %v", err)
1476+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
14781477
}
14791478
}()
14801479
<-starting
@@ -1535,7 +1534,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
15351534
go func() {
15361535
defer pending.Done()
15371536
if err := tester.sync("faulty", nil, mode); err == nil {
1538-
t.Fatalf("succeeded faulty synchronisation")
1537+
panic("succeeded faulty synchronisation")
15391538
}
15401539
}()
15411540
<-starting
@@ -1552,7 +1551,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
15521551
go func() {
15531552
defer pending.Done()
15541553
if err := tester.sync("valid", nil, mode); err != nil {
1555-
t.Fatalf("failed to synchronise blocks: %v", err)
1554+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
15561555
}
15571556
}()
15581557
<-starting
@@ -1613,7 +1612,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
16131612
go func() {
16141613
defer pending.Done()
16151614
if err := tester.sync("attack", nil, mode); err == nil {
1616-
t.Fatalf("succeeded attacker synchronisation")
1615+
panic("succeeded attacker synchronisation")
16171616
}
16181617
}()
16191618
<-starting
@@ -1630,7 +1629,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) {
16301629
go func() {
16311630
defer pending.Done()
16321631
if err := tester.sync("valid", nil, mode); err != nil {
1633-
t.Fatalf("failed to synchronise blocks: %v", err)
1632+
panic(fmt.Sprintf("failed to synchronise blocks: %v", err))
16341633
}
16351634
}()
16361635
<-starting

‎eth/filters/api.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type PublicFilterAPI struct {
5454
backend Backend
5555
useMipMap bool
5656
mux *event.TypeMux
57-
quit chan struct{}
5857
chainDb ethdb.Database
5958
events *EventSystem
6059
filtersMu sync.Mutex

‎eth/filters/filter.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"math"
2222
"math/big"
23-
"time"
2423

2524
"github.com/ethereum/go-ethereum/common"
2625
"github.com/ethereum/go-ethereum/core"
@@ -42,8 +41,6 @@ type Filter struct {
4241
backend Backend
4342
useMipMap bool
4443

45-
created time.Time
46-
4744
db ethdb.Database
4845
begin, end int64
4946
addresses []common.Address

‎eth/filters/filter_system.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type subscription struct {
7474
// subscription which match the subscription criteria.
7575
type EventSystem struct {
7676
mux *event.TypeMux
77-
sub *event.TypeMuxSubscription
7877
backend Backend
7978
lightMode bool
8079
lastHead *types.Header

‎eth/filters/filter_system_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package filters
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"math/big"
2223
"reflect"
2324
"testing"
@@ -439,15 +440,15 @@ func TestPendingLogsSubscription(t *testing.T) {
439440
}
440441

441442
if len(fetched) != len(tt.expected) {
442-
t.Fatalf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched))
443+
panic(fmt.Sprintf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched)))
443444
}
444445

445446
for l := range fetched {
446447
if fetched[l].Removed {
447-
t.Errorf("expected log not to be removed for log %d in case %d", l, i)
448+
panic(fmt.Sprintf("expected log not to be removed for log %d in case %d", l, i))
448449
}
449450
if !reflect.DeepEqual(fetched[l], tt.expected[l]) {
450-
t.Errorf("invalid log on index %d for case %d", l, i)
451+
panic(fmt.Sprintf("invalid log on index %d for case %d", l, i))
451452
}
452453
}
453454
}()

‎eth/sync.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func (pm *ProtocolManager) syncer() {
138138
defer pm.downloader.Terminate()
139139

140140
// Wait for different events to fire synchronisation operations
141-
forceSync := time.Tick(forceSyncCycle)
141+
forceSync := time.NewTicker(forceSyncCycle)
142+
defer forceSync.Stop()
143+
142144
for {
143145
select {
144146
case <-pm.newPeerCh:
@@ -148,7 +150,7 @@ func (pm *ProtocolManager) syncer() {
148150
}
149151
go pm.synchronise(pm.peers.BestPeer())
150152

151-
case <-forceSync:
153+
case <-forceSync.C:
152154
// Force a sync even if not enough peers are present
153155
go pm.synchronise(pm.peers.BestPeer())
154156

0 commit comments

Comments
 (0)