Browse Source

linter fixes

pull/3907/head
Sean Braithwaite 5 years ago
parent
commit
2c8cbfc26a
4 changed files with 10 additions and 12 deletions
  1. +2
    -0
      blockchain/v2/demuxer.go
  2. +4
    -11
      blockchain/v2/reactor.go
  3. +1
    -0
      blockchain/v2/routine.go
  4. +3
    -1
      blockchain/v2/routine_test.go

+ 2
- 0
blockchain/v2/demuxer.go View File

@ -1,3 +1,4 @@
// nolint:unused
package v2
import (
@ -46,6 +47,7 @@ func (dm *demuxer) start() {
panic("Routine has already started")
}
dm.logger.Info("demuxer: run")
dm.rdy <- struct{}{}
for {
if !dm.isRunning() {
break


+ 4
- 11
blockchain/v2/reactor.go View File

@ -8,7 +8,6 @@ import (
)
type timeCheck struct {
time time.Time
}
func schedulerHandle(event Event) (Events, error) {
@ -31,15 +30,14 @@ func processorHandle(event Event) (Events, error) {
return Events{}, nil
}
// reactor
type Reactor struct {
demuxer *demuxer
scheduler *Routine
processor *Routine
ticker *time.Ticker
tickerStopped chan struct{}
}
// nolint:unused
func (r *Reactor) setLogger(logger log.Logger) {
r.scheduler.setLogger(logger)
r.processor.setLogger(logger)
@ -56,14 +54,9 @@ func (r *Reactor) Start() {
go r.processor.start()
go r.demuxer.start()
for {
if r.scheduler.isRunning() && r.processor.isRunning() && r.demuxer.isRunning() {
fmt.Println("routines running")
break
}
fmt.Println("waiting")
time.Sleep(10 * time.Millisecond)
}
<-r.scheduler.ready()
<-r.processor.ready()
<-r.demuxer.ready()
go func() {
ticker := time.NewTicker(1 * time.Second)


+ 1
- 0
blockchain/v2/routine.go View File

@ -50,6 +50,7 @@ func (rt *Routine) setLogger(logger log.Logger) {
rt.logger = logger
}
// nolint:unused
func (rt *Routine) setMetrics(metrics *Metrics) {
rt.metrics = metrics
}


+ 3
- 1
blockchain/v2/routine_test.go View File

@ -41,7 +41,7 @@ func TestRoutine(t *testing.T) {
"expected the final event to be done")
}
func TesRoutineSend(t *testing.T) {
func TestRoutineSend(t *testing.T) {
routine := newRoutine("simpleRoutine", simpleHandler)
assert.False(t, routine.trySend(eventA{}),
@ -81,6 +81,8 @@ func genStatefulHandler(maxCount int) handleFunc {
}
return Events{eventA{}}, nil
case eventB:
return Events{}, nil
}
return Events{}, nil
}


Loading…
Cancel
Save