Documentation ¶
Index ¶
- Constants
- func HashMessage(msg trcpb.TraceMsgItfc) []byte
- type ChannelResponseHandler
- 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 agtypes.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 []byte, data []byte, onlyValidator bool) (broadcast bool, err error)
- func (rt *Router) TraceRespond(requestHash []byte, data []byte) ([]byte, error)
Constants ¶
const ( // SpecialOPChannel is for special operation only SpecialOPChannel = byte(0x50) )
Variables ¶
This section is empty.
Functions ¶
func HashMessage ¶
func HashMessage(msg trcpb.TraceMsgItfc) []byte
Types ¶
type ChannelResponseHandler ¶
ChannelResponseHandler defines the signature of the handler for a channel. Very cheap design, just []byte in & out.
type Reactor ¶
type Reactor struct { // every reactor implements p2p.BaseReactor p2p.BaseReactor // contains filtered or unexported fields }
func NewTraceReactor ¶
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 ¶
func (tr *Reactor) RemovePeer(peer *p2p.Peer, reason interface{})
RemovePeer has nothing to do
func (*Reactor) SetEventSwitch ¶
func (tr *Reactor) SetEventSwitch(evsw agtypes.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 NewRouter ¶
func NewRouter(logger *zap.Logger, config *viper.Viper, state *sm.State, priv *agtypes.PrivValidator) *Router
NewRouter defines the constructor of Router, initialization.
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.