diff options
author | Egon Elbre <egonelbre@gmail.com> | 2017-08-06 13:54:25 +0800 |
---|---|---|
committer | Egon Elbre <egonelbre@gmail.com> | 2017-08-08 00:54:20 +0800 |
commit | 8f06b7980dd2b6023ee7657d28da5567cdda4fcc (patch) | |
tree | 8b67d622446f9ae874df555e41a5709c99ce3431 /eth | |
parent | 971079822ee6c12d9348ec78f212fe91c9b83edf (diff) | |
download | dexon-8f06b7980dd2b6023ee7657d28da5567cdda4fcc.tar.gz dexon-8f06b7980dd2b6023ee7657d28da5567cdda4fcc.tar.zst dexon-8f06b7980dd2b6023ee7657d28da5567cdda4fcc.zip |
eth: fix megacheck warnings
Diffstat (limited to 'eth')
-rw-r--r-- | eth/api.go | 20 | ||||
-rw-r--r-- | eth/downloader/downloader_test.go | 19 | ||||
-rw-r--r-- | eth/filters/api.go | 1 | ||||
-rw-r--r-- | eth/filters/filter.go | 3 | ||||
-rw-r--r-- | eth/filters/filter_system.go | 1 | ||||
-rw-r--r-- | eth/filters/filter_system_test.go | 7 | ||||
-rw-r--r-- | eth/sync.go | 6 |
7 files changed, 17 insertions, 40 deletions
diff --git a/eth/api.go b/eth/api.go index 0d90759b6..f5214fc37 100644 --- a/eth/api.go +++ b/eth/api.go @@ -465,26 +465,6 @@ func (api *PrivateDebugAPI) traceBlock(block *types.Block, logConfig *vm.LogConf return true, structLogger.StructLogs(), nil } -// callmsg is the message type used for call transitions. -type callmsg struct { - addr common.Address - to *common.Address - gas, gasPrice *big.Int - value *big.Int - data []byte -} - -// accessor boilerplate to implement core.Message -func (m callmsg) From() (common.Address, error) { return m.addr, nil } -func (m callmsg) FromFrontier() (common.Address, error) { return m.addr, nil } -func (m callmsg) Nonce() uint64 { return 0 } -func (m callmsg) CheckNonce() bool { return false } -func (m callmsg) To() *common.Address { return m.to } -func (m callmsg) GasPrice() *big.Int { return m.gasPrice } -func (m callmsg) Gas() *big.Int { return m.gas } -func (m callmsg) Value() *big.Int { return m.value } -func (m callmsg) Data() []byte { return m.data } - // formatError formats a Go error into either an empty string or the data content // of the error itself. func formatError(err error) string { diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index b354682a1..36e8c800f 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -403,8 +403,7 @@ func (dl *downloadTester) newSlowPeer(id string, version int, hashes []common.Ha dl.lock.Lock() defer dl.lock.Unlock() - var err error - err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl, id, delay}) + var err = dl.downloader.RegisterPeer(id, version, &downloadTesterPeer{dl, id, delay}) if err == nil { // Assign the owned hashes, headers and blocks to the peer (deep copy) dl.peerHashes[id] = make([]common.Hash, len(hashes)) @@ -1381,7 +1380,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("peer-half", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting @@ -1398,7 +1397,7 @@ func testSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("peer-full", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting @@ -1454,7 +1453,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("fork A", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting @@ -1474,7 +1473,7 @@ func testForkedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("fork B", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting @@ -1535,7 +1534,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("faulty", nil, mode); err == nil { - t.Fatalf("succeeded faulty synchronisation") + panic("succeeded faulty synchronisation") } }() <-starting @@ -1552,7 +1551,7 @@ func testFailedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("valid", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting @@ -1613,7 +1612,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("attack", nil, mode); err == nil { - t.Fatalf("succeeded attacker synchronisation") + panic("succeeded attacker synchronisation") } }() <-starting @@ -1630,7 +1629,7 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) { go func() { defer pending.Done() if err := tester.sync("valid", nil, mode); err != nil { - t.Fatalf("failed to synchronise blocks: %v", err) + panic(fmt.Sprintf("failed to synchronise blocks: %v", err)) } }() <-starting diff --git a/eth/filters/api.go b/eth/filters/api.go index 61647a5d0..fff58a268 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -54,7 +54,6 @@ type PublicFilterAPI struct { backend Backend useMipMap bool mux *event.TypeMux - quit chan struct{} chainDb ethdb.Database events *EventSystem filtersMu sync.Mutex diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 0a0b81224..f27b76929 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -20,7 +20,6 @@ import ( "context" "math" "math/big" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -42,8 +41,6 @@ type Filter struct { backend Backend useMipMap bool - created time.Time - db ethdb.Database begin, end int64 addresses []common.Address diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 7abace1e6..ab0b7473e 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -74,7 +74,6 @@ type subscription struct { // subscription which match the subscription criteria. type EventSystem struct { mux *event.TypeMux - sub *event.TypeMuxSubscription backend Backend lightMode bool lastHead *types.Header diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 822580b56..23e6d66e1 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -18,6 +18,7 @@ package filters import ( "context" + "fmt" "math/big" "reflect" "testing" @@ -439,15 +440,15 @@ func TestPendingLogsSubscription(t *testing.T) { } if len(fetched) != len(tt.expected) { - t.Fatalf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched)) + panic(fmt.Sprintf("invalid number of logs for case %d, want %d log(s), got %d", i, len(tt.expected), len(fetched))) } for l := range fetched { if fetched[l].Removed { - t.Errorf("expected log not to be removed for log %d in case %d", l, i) + panic(fmt.Sprintf("expected log not to be removed for log %d in case %d", l, i)) } if !reflect.DeepEqual(fetched[l], tt.expected[l]) { - t.Errorf("invalid log on index %d for case %d", l, i) + panic(fmt.Sprintf("invalid log on index %d for case %d", l, i)) } } }() diff --git a/eth/sync.go b/eth/sync.go index 8784b225d..7442f912c 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -138,7 +138,9 @@ func (pm *ProtocolManager) syncer() { defer pm.downloader.Terminate() // Wait for different events to fire synchronisation operations - forceSync := time.Tick(forceSyncCycle) + forceSync := time.NewTicker(forceSyncCycle) + defer forceSync.Stop() + for { select { case <-pm.newPeerCh: @@ -148,7 +150,7 @@ func (pm *ProtocolManager) syncer() { } go pm.synchronise(pm.peers.BestPeer()) - case <-forceSync: + case <-forceSync.C: // Force a sync even if not enough peers are present go pm.synchronise(pm.peers.BestPeer()) |