trace

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2018 License: LGPL-3.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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

type ChannelResponseHandler func([]byte) []byte

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 NewTraceReactor(logger *zap.Logger, config *viper.Viper, r *Router) *Reactor

func (*Reactor) AddPeer

func (tr *Reactor) AddPeer(peer *p2p.Peer)

AddPeer has nothing to do

func (*Reactor) GetChannels

func (tr *Reactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels returns channel descriptor for all supported channels. maybe more in the furture

func (*Reactor) OnStart

func (tr *Reactor) OnStart() error

func (*Reactor) OnStop

func (tr *Reactor) OnStop()

func (*Reactor) Receive

func (tr *Reactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)

Receive is the main entrance of handling data flow

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) Broadcast

func (rt *Router) Broadcast(ctx context.Context, data []byte, voteCh chan []byte) error

Broadcast is the entry for start a traced communication. thread-safe

func (*Router) RegisterHandler

func (rt *Router) RegisterHandler(chID byte, fn ChannelResponseHandler) error

RegisterHandler binds a channel with the specified handler.

func (*Router) Requesthash

func (rt *Router) Requesthash(data []byte) []byte

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

func (rt *Router) SetReactor(r *Reactor)

SetReactor binds with a trace reactor.

func (*Router) TraceRequest

func (rt *Router) TraceRequest(requestHash []byte, fromPeer []byte, data []byte, onlyValidator bool) (broadcast bool, err error)

TraceRequest is a thread-safe wrapper of the processing of request.

func (*Router) TraceRespond

func (rt *Router) TraceRespond(requestHash []byte, data []byte) ([]byte, error)

TraceRespond is a thread-safe wrapper of handling response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL