diff --git a/blockchain/v2/demuxer.go b/blockchain/v2/demuxer.go index 9ae4c3f38..6b9df0f50 100644 --- a/blockchain/v2/demuxer.go +++ b/blockchain/v2/demuxer.go @@ -5,6 +5,9 @@ import ( "sync/atomic" ) +type scFull struct{} +type pcFull struct{} + type demuxer struct { input chan Event scheduler *Routine diff --git a/blockchain/v2/reactor.go b/blockchain/v2/reactor.go index 85f669739..0a12f385c 100644 --- a/blockchain/v2/reactor.go +++ b/blockchain/v2/reactor.go @@ -5,13 +5,16 @@ import ( "time" ) +type timeCheck struct { + time time.Time +} + func schedulerHandle(event Event) (Events, error) { switch event.(type) { case timeCheck: fmt.Println("scheduler handle timeCheck") - case testEvent: + case Event: fmt.Println("scheduler handle testEvent") - return Events{scTestEvent{}}, nil } return Events{}, nil } @@ -20,11 +23,8 @@ func processorHandle(event Event) (Events, error) { switch event.(type) { case timeCheck: fmt.Println("processor handle timeCheck") - case testEvent: - fmt.Println("processor handle testEvent") - case scTestEvent: - fmt.Println("processor handle scTestEvent") - return Events{}, fmt.Errorf("processor done") + case Event: + fmt.Println("processor handle event") } return Events{}, nil } @@ -40,10 +40,8 @@ type Reactor struct { // TODO: setLogger should set loggers of the routines func (r *Reactor) Start() { - // what is the best way to get the events out of the routine r.scheduler = newRoutine("scheduler", schedulerHandle) r.processor = newRoutine("processor", processorHandle) - // so actually the demuxer only needs to read from events r.demuxer = newDemuxer(r.scheduler, r.processor) r.tickerStopped = make(chan struct{}) diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index b3430074f..d075641f7 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -7,7 +7,7 @@ func TestReactor(t *testing.T) { reactor := Reactor{} reactor.Start() script := Events{ - testEvent{}, + struct{}{}, } for _, event := range script { diff --git a/blockchain/v2/routine_test.go b/blockchain/v2/routine_test.go index cbf4768a8..cb7944ba3 100644 --- a/blockchain/v2/routine_test.go +++ b/blockchain/v2/routine_test.go @@ -11,6 +11,7 @@ import ( type eventA struct{} type eventB struct{} +type errEvent struct{} var done = fmt.Errorf("done") diff --git a/blockchain/v2/types.go b/blockchain/v2/types.go index e6f491460..dbde352a3 100644 --- a/blockchain/v2/types.go +++ b/blockchain/v2/types.go @@ -1,35 +1,4 @@ package v2 -import "time" - type Event interface{} - type Events []Event -type testEvent struct { - msg string - time time.Time -} - -type testEventTwo struct { - msg string -} - -type stopEvent struct{} -type timeCheck struct { - time time.Time -} - -type errEvent struct{} - -type scTestEvent struct{} - -type pcFinished struct{} - -type routineFinished struct{} - -func (rf *routineFinished) Error() string { - return "routine finished" -} - -type scFull struct{} -type pcFull struct{}