Browse Source

changes based on feedback

pull/3878/head
Sean Braithwaite 5 years ago
parent
commit
fbede85e20
2 changed files with 6 additions and 3 deletions
  1. +4
    -3
      blockchain/v2/reactor.go
  2. +2
    -0
      blockchain/v2/routine.go

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

@ -73,11 +73,12 @@ func (r *Reactor) Start() {
}()
}
// Would it be possible here to provide some kind of type safety for the types
// of events that each routine can produce and consume?
func (r *Reactor) demux() {
for {
select {
case event := <-r.events:
// XXX: check for backpressure
r.scheduler.trySend(event)
r.processor.trySend(event)
@ -85,9 +86,9 @@ func (r *Reactor) demux() {
r.logger.Info("demuxing stopped")
return
case event := <-r.scheduler.next():
r.events <- event
r.processor.trySend(event)
case event := <-r.processor.next():
r.events <- event
r.scheduler.trySend(event)
case err := <-r.scheduler.final():
r.logger.Info(fmt.Sprintf("scheduler final %s", err))
case err := <-r.processor.final():


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

@ -92,6 +92,8 @@ func (rt *Routine) start() {
}
}
// XXX: rename send
// XXX: look into returning OpError in the net package
func (rt *Routine) trySend(event Event) bool {
rt.logger.Info(fmt.Sprintf("%s: sending %+v", rt.name, event))
if !rt.isRunning() {


Loading…
Cancel
Save