Documentation ¶
Index ¶
- Constants
- func HashMessage(o Message) []byte
- type ChannelResponseHandler
- type Message
- type Reactor
- func (tr *Reactor) AddPeer(peer *p2p.Peer)
- func (tr *Reactor) GetChannels() []*p2p.ChannelDescriptor
- func (tr *Reactor) OnStart() error
- func (tr *Reactor) OnStop()
- func (tr *Reactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
- func (tr *Reactor) RemovePeer(peer *p2p.Peer, reason interface{})
- func (tr *Reactor) SetEventSwitch(evsw atypes.EventSwitch)
- type Router
- func (rt *Router) Broadcast(ctx context.Context, data []byte, voteCh chan []byte) error
- func (rt *Router) RegisterHandler(chID byte, fn ChannelResponseHandler) error
- func (rt *Router) Requesthash(data []byte) []byte
- func (rt *Router) SetPrivValidator(priv *agtypes.PrivValidator)
- func (rt *Router) SetReactor(r *Reactor)
- func (rt *Router) TraceRequest(requestHash []byte, fromPeer string, data []byte, onlyValidator bool) (broadcast bool, err error)
- func (rt *Router) TraceRespond(requestHash []byte, data []byte) ([]byte, error)
Constants ¶
const ( // AdminOPChannel is for admin operation only AdminOPChannel = byte(0x50) )
Variables ¶
This section is empty.
Functions ¶
func HashMessage ¶
Types ¶
type ChannelResponseHandler ¶
ChannelResponseHandler defines the signature of the handler for a channel. Very cheap design, just []byte in & out.
type Message ¶
type Message interface{}
TraceMessage is just a wrapper which conforms to the usage of wire.RegisterInterface
type Reactor ¶
type Reactor struct { // every reactor implements p2p.BaseReactor p2p.BaseReactor // contains filtered or unexported fields }
func (*Reactor) GetChannels ¶
func (tr *Reactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels returns channel descriptor for all supported channels. maybe more in the furture
func (*Reactor) RemovePeer ¶
RemovePeer has nothing to do
func (*Reactor) SetEventSwitch ¶
func (tr *Reactor) SetEventSwitch(evsw atypes.EventSwitch)
type Router ¶
type Router struct { cmn.BaseService // contains filtered or unexported fields }
Router keeps tracks of the messages flow around in the TraceReactor. Messages are wrapped in the "TraceMessage" envelope universally. And messages are identified by Hash uniquely in the Router. Different purposes and related handlers are separated by ChannelID.
func (*Router) RegisterHandler ¶
func (rt *Router) RegisterHandler(chID byte, fn ChannelResponseHandler) error
RegisterHandler binds a channel with the specified handler.
func (*Router) Requesthash ¶
Requesthash hashes a message in []byte as the identification of this message.
func (*Router) SetPrivValidator ¶
func (rt *Router) SetPrivValidator(priv *agtypes.PrivValidator)
SetPrivValidator
func (*Router) SetReactor ¶
SetReactor binds with a trace reactor.