From d42ce0f2c1b52e26cce475e411d97165fb975577 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Mon, 30 Jul 2018 11:30:09 +0200 Subject: all: simplify switches (#17267) * all: simplify switches * silly mistake --- eth/filters/filter_system.go | 3 +-- eth/handler.go | 3 +-- eth/tracers/tracer.go | 7 +------ 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'eth') diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 4e999cda8..70139c1a9 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -338,8 +338,7 @@ func (es *EventSystem) broadcast(filters filterIndex, ev interface{}) { } } case *event.TypeMuxEvent: - switch muxe := e.Data.(type) { - case core.PendingLogsEvent: + if muxe, ok := e.Data.(core.PendingLogsEvent); ok { for _, f := range filters[PendingLogsSubscription] { if e.Time.After(f.created) { if matchedLogs := filterLogs(muxe.Logs, nil, f.logsCrit.ToBlock, f.logsCrit.Addresses, f.logsCrit.Topics); len(matchedLogs) > 0 { diff --git a/eth/handler.go b/eth/handler.go index f2d2eaf1c..f89f68c9d 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -744,8 +744,7 @@ func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions) { func (pm *ProtocolManager) minedBroadcastLoop() { // automatically stops if unsubscribe for obj := range pm.minedBlockSub.Chan() { - switch ev := obj.Data.(type) { - case core.NewMinedBlockEvent: + if ev, ok := obj.Data.(core.NewMinedBlockEvent); ok { pm.BroadcastBlock(ev.Block, true) // First propagate block to peers pm.BroadcastBlock(ev.Block, false) // Only then announce to the rest } diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 4cec9e633..feb57e060 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -486,12 +486,7 @@ func (jst *Tracer) call(method string, args ...string) (json.RawMessage, error) } func wrapError(context string, err error) error { - var message string - switch err := err.(type) { - default: - message = err.Error() - } - return fmt.Errorf("%v in server-side tracer function '%v'", message, context) + return fmt.Errorf("%v in server-side tracer function '%v'", err, context) } // CaptureStart implements the Tracer interface to initialize the tracing operation. -- cgit v1.2.3