You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
604 B

  1. package consensus
  2. import (
  3. "github.com/tendermint/tendermint/types"
  4. )
  5. // XXX: WARNING: this function can halt the consensus as firing events is synchronous.
  6. // Make sure to read off the channels, and in the case of subscribeToEventRespond, to write back on it
  7. // NOTE: if chanCap=0, this blocks on the event being consumed
  8. func subscribeToEvent(evsw types.EventSwitch, receiver, eventID string, chanCap int) chan interface{} {
  9. // listen for event
  10. ch := make(chan interface{}, chanCap)
  11. types.AddListenerForEvent(evsw, receiver, eventID, func(data types.TMEventData) {
  12. ch <- data
  13. })
  14. return ch
  15. }