2015-04-13 18:26:41 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2016-01-13 18:38:55 -05:00
|
|
|
// for registering TMEventData as events.EventData
|
2016-01-12 16:54:27 -05:00
|
|
|
"github.com/tendermint/go-events"
|
2015-10-22 17:39:06 -07:00
|
|
|
"github.com/tendermint/go-wire"
|
2015-04-13 18:26:41 -07:00
|
|
|
)
|
|
|
|
|
2015-04-15 19:14:08 -07:00
|
|
|
// Functions to generate eventId strings
|
|
|
|
|
2015-12-01 20:12:01 -08:00
|
|
|
// Reserved
|
|
|
|
func EventStringBond() string { return "Bond" }
|
|
|
|
func EventStringUnbond() string { return "Unbond" }
|
|
|
|
func EventStringRebond() string { return "Rebond" }
|
|
|
|
func EventStringDupeout() string { return "Dupeout" }
|
|
|
|
func EventStringFork() string { return "Fork" }
|
|
|
|
|
|
|
|
func EventStringNewBlock() string { return "NewBlock" }
|
|
|
|
func EventStringNewRound() string { return "NewRound" }
|
2015-12-13 19:30:15 -05:00
|
|
|
func EventStringNewRoundStep() string { return "NewRoundStep" }
|
2015-12-01 20:12:01 -08:00
|
|
|
func EventStringTimeoutPropose() string { return "TimeoutPropose" }
|
|
|
|
func EventStringCompleteProposal() string { return "CompleteProposal" }
|
|
|
|
func EventStringPolka() string { return "Polka" }
|
|
|
|
func EventStringUnlock() string { return "Unlock" }
|
|
|
|
func EventStringLock() string { return "Lock" }
|
|
|
|
func EventStringRelock() string { return "Relock" }
|
|
|
|
func EventStringTimeoutWait() string { return "TimeoutWait" }
|
|
|
|
func EventStringVote() string { return "Vote" }
|
2015-09-09 16:45:53 -04:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
//----------------------------------------
|
|
|
|
|
2016-01-13 18:38:55 -05:00
|
|
|
// implements events.EventData
|
|
|
|
type TMEventData interface {
|
|
|
|
events.EventData
|
|
|
|
// AssertIsTMEventData()
|
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
const (
|
|
|
|
EventDataTypeNewBlock = byte(0x01)
|
|
|
|
EventDataTypeFork = byte(0x02)
|
|
|
|
EventDataTypeTx = byte(0x03)
|
2015-09-09 16:45:53 -04:00
|
|
|
|
|
|
|
EventDataTypeRoundState = byte(0x11)
|
|
|
|
EventDataTypeVote = byte(0x12)
|
2015-08-10 20:38:45 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = wire.RegisterInterface(
|
2016-01-13 18:38:55 -05:00
|
|
|
struct{ TMEventData }{},
|
2015-08-10 20:38:45 -07:00
|
|
|
wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock},
|
2015-08-11 12:46:33 -07:00
|
|
|
// wire.ConcreteType{EventDataFork{}, EventDataTypeFork },
|
2015-08-10 20:38:45 -07:00
|
|
|
wire.ConcreteType{EventDataTx{}, EventDataTypeTx},
|
2015-09-09 16:45:53 -04:00
|
|
|
wire.ConcreteType{EventDataRoundState{}, EventDataTypeRoundState},
|
|
|
|
wire.ConcreteType{EventDataVote{}, EventDataTypeVote},
|
2015-08-10 20:38:45 -07:00
|
|
|
)
|
|
|
|
|
2015-04-15 19:14:08 -07:00
|
|
|
// Most event messages are basic types (a block, a transaction)
|
2015-09-09 16:45:53 -04:00
|
|
|
// but some (an input to a call tx or a receive) are more exotic
|
2015-04-15 19:14:08 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type EventDataNewBlock struct {
|
|
|
|
Block *Block `json:"block"`
|
|
|
|
}
|
|
|
|
|
2015-12-01 20:12:01 -08:00
|
|
|
// All txs fire EventDataTx
|
2015-08-10 20:38:45 -07:00
|
|
|
type EventDataTx struct {
|
2016-01-25 14:34:08 -08:00
|
|
|
Tx Tx `json:"tx"`
|
|
|
|
Result []byte `json:"result"`
|
|
|
|
Log string `json:"log"`
|
|
|
|
Error string `json:"error"`
|
2015-04-15 19:14:08 -07:00
|
|
|
}
|
2015-08-11 12:46:33 -07:00
|
|
|
|
2016-01-28 19:53:22 -08:00
|
|
|
// NOTE: This goes into the replay WAL
|
2015-09-09 16:45:53 -04:00
|
|
|
type EventDataRoundState struct {
|
2015-12-14 00:38:19 -05:00
|
|
|
Height int `json:"height"`
|
|
|
|
Round int `json:"round"`
|
|
|
|
Step string `json:"step"`
|
|
|
|
|
|
|
|
// private, not exposed to websockets
|
2016-01-14 11:07:31 -08:00
|
|
|
RoundState interface{} `json:"-"`
|
2015-09-09 16:45:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type EventDataVote struct {
|
|
|
|
Index int
|
|
|
|
Address []byte
|
|
|
|
Vote *Vote
|
|
|
|
}
|
|
|
|
|
2016-01-13 18:38:55 -05:00
|
|
|
func (_ EventDataNewBlock) AssertIsTMEventData() {}
|
|
|
|
func (_ EventDataTx) AssertIsTMEventData() {}
|
|
|
|
func (_ EventDataRoundState) AssertIsTMEventData() {}
|
|
|
|
func (_ EventDataVote) AssertIsTMEventData() {}
|