Browse Source

events: remove service aspects of event switch

pull/8146/head
tycho garen 3 years ago
parent
commit
748d6885c9
3 changed files with 0 additions and 37 deletions
  1. +0
    -16
      internal/consensus/state.go
  2. +0
    -10
      libs/events/events.go
  3. +0
    -11
      libs/events/events_test.go

+ 0
- 16
internal/consensus/state.go View File

@ -456,10 +456,6 @@ func (cs *State) OnStart(ctx context.Context) error {
}
}
if err := cs.evsw.Start(ctx); err != nil {
return err
}
// Double Signing Risk Reduction
if err := cs.checkDoubleSigningRisk(cs.Height); err != nil {
return err
@ -514,24 +510,12 @@ func (cs *State) OnStop() {
close(cs.onStopCh)
if cs.evsw.IsRunning() {
cs.evsw.Stop()
}
if cs.timeoutTicker.IsRunning() {
cs.timeoutTicker.Stop()
}
// WAL is stopped in receiveRoutine.
}
// Wait waits for the the main routine to return.
// NOTE: be sure to Stop() the event switch and drain
// any event channels or this may deadlock
func (cs *State) Wait() {
cs.evsw.Wait()
<-cs.done
}
// OpenWAL opens a file to log all consensus messages and timeouts for
// deterministic accountability.
func (cs *State) OpenWAL(ctx context.Context, walFile string) (WAL, error) {


+ 0
- 10
libs/events/events.go View File

@ -7,7 +7,6 @@ import (
"sync"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service"
)
// ErrListenerWasRemoved is returned by AddEvent if the listener was removed.
@ -45,16 +44,11 @@ type Fireable interface {
// They can be removed by calling either RemoveListenerForEvent or
// RemoveListener (for all events).
type EventSwitch interface {
service.Service
Fireable
Stop()
AddListenerForEvent(listenerID, eventValue string, cb EventCallback) error
}
type eventSwitch struct {
service.BaseService
mtx sync.RWMutex
eventCells map[string]*eventCell
listeners map[string]*eventListener
@ -65,13 +59,9 @@ func NewEventSwitch(logger log.Logger) EventSwitch {
eventCells: make(map[string]*eventCell),
listeners: make(map[string]*eventListener),
}
evsw.BaseService = *service.NewBaseService(logger, "EventSwitch", evsw)
return evsw
}
func (evsw *eventSwitch) OnStart(ctx context.Context) error { return nil }
func (evsw *eventSwitch) OnStop() {}
func (evsw *eventSwitch) AddListenerForEvent(listenerID, eventValue string, cb EventCallback) error {
// Get/Create eventCell and listener.
evsw.mtx.Lock()


+ 0
- 11
libs/events/events_test.go View File

@ -21,8 +21,6 @@ func TestAddListenerForEventFireOnce(t *testing.T) {
logger := log.NewTestingLogger(t)
evsw := NewEventSwitch(logger)
require.NoError(t, evsw.Start(ctx))
t.Cleanup(evsw.Wait)
messages := make(chan EventData)
require.NoError(t, evsw.AddListenerForEvent("listener", "event",
@ -50,8 +48,6 @@ func TestAddListenerForEventFireMany(t *testing.T) {
logger := log.NewTestingLogger(t)
evsw := NewEventSwitch(logger)
require.NoError(t, evsw.Start(ctx))
t.Cleanup(evsw.Wait)
doneSum := make(chan uint64)
doneSending := make(chan uint64)
@ -88,8 +84,6 @@ func TestAddListenerForDifferentEvents(t *testing.T) {
logger := log.NewTestingLogger(t)
evsw := NewEventSwitch(logger)
require.NoError(t, evsw.Start(ctx))
t.Cleanup(evsw.Wait)
doneSum := make(chan uint64)
doneSending1 := make(chan uint64)
@ -151,9 +145,6 @@ func TestAddDifferentListenerForDifferentEvents(t *testing.T) {
logger := log.NewTestingLogger(t)
evsw := NewEventSwitch(logger)
require.NoError(t, evsw.Start(ctx))
t.Cleanup(evsw.Wait)
doneSum1 := make(chan uint64)
doneSum2 := make(chan uint64)
@ -247,8 +238,6 @@ func TestManageListenersAsync(t *testing.T) {
logger := log.NewTestingLogger(t)
evsw := NewEventSwitch(logger)
require.NoError(t, evsw.Start(ctx))
t.Cleanup(evsw.Wait)
doneSum1 := make(chan uint64)
doneSum2 := make(chan uint64)


Loading…
Cancel
Save