Documentation ¶
Index ¶
- Variables
- func DecodeHex(hexString string) (data []byte)
- func EnableP2PLogging()
- func SyncLogger()
- type Catchup
- type Client
- type Envelope
- type Handler
- type HandlerFunc
- type HandshakeInfo
- type Peer
- func (p *Peer) Connect(errChan chan error) (ready chan bool)
- func (p Peer) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (p *Peer) Read() (*eos.Packet, error)
- func (p *Peer) SendHandshake(info *HandshakeInfo) (err error)
- func (p *Peer) SendNotice(headBlockNum uint32, libNum uint32, mode byte) (err error)
- func (p *Peer) SendRequest(startBlockNum uint32, endBlockNumber uint32) (err error)
- func (p *Peer) SendSyncRequest(startBlockNum uint32, endBlockNumber uint32) (err error)
- func (p *Peer) SendTime() (err error)
- func (p *Peer) SetConnection(conn net.Conn)
- func (p *Peer) SetConnectionTimeout(timeout time.Duration)
- func (p *Peer) SetHandshakeTimeout(timeout time.Duration)
- func (p *Peer) Write(bytes []byte) (int, error)
- func (p *Peer) WriteP2PMessage(message eos.P2PMessage) (err error)
- type Proxy
- type Relay
Constants ¶
This section is empty.
Variables ¶
View Source
var LoggerHandler = HandlerFunc(func(envelope *Envelope) { data, err := json.Marshal(envelope) if err != nil { logErr("Marshal err", err) return } p2pLog.Info("handler", zap.String("message", string(data))) })
LoggerHandler logs the messages back and forth.
View Source
var StringLoggerHandler = HandlerFunc(func(envelope *Envelope) { name, _ := envelope.Packet.Type.Name() p2pLog.Info( "handler Packet", zap.String("name", name), zap.String("sender", envelope.Sender.Address), zap.String("receiver", envelope.Receiver.Address), zap.Stringer("msg", envelope.Packet.P2PMessage), ) })
StringLoggerHandler simply prints the messages as they go through the client.
Functions ¶
func SyncLogger ¶
func SyncLogger()
SyncLogger sync logger, should `defer SyncLogger()` when use p2p package
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CloseConnection ¶
func (*Client) RegisterHandler ¶
func (*Client) SetReadTimeout ¶
type Envelope ¶
func NewEnvelope ¶
type HandlerFunc ¶
type HandlerFunc func(envelope *Envelope)
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(envelope *Envelope)
type HandshakeInfo ¶
type HandshakeInfo struct { ChainID eos.Checksum256 HeadBlockNum uint32 HeadBlockID eos.Checksum256 HeadBlockTime time.Time LastIrreversibleBlockNum uint32 LastIrreversibleBlockID eos.Checksum256 }
func (HandshakeInfo) MarshalLogObject ¶
func (h HandshakeInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject calls the underlying function from zap.
func (*HandshakeInfo) String ¶
func (h *HandshakeInfo) String() string
type Peer ¶
type Peer struct { Address string Name string NodeID []byte // contains filtered or unexported fields }
func NewIncommingPeer ¶
func NewOutgoingPeer ¶
func NewOutgoingPeer(address string, agent string, handshakeInfo *HandshakeInfo) *Peer
func (Peer) MarshalLogObject ¶
func (p Peer) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject calls the underlying function from zap.
func (*Peer) SendHandshake ¶
func (p *Peer) SendHandshake(info *HandshakeInfo) (err error)
func (*Peer) SendNotice ¶
func (*Peer) SendRequest ¶
func (*Peer) SendSyncRequest ¶
func (*Peer) SetConnection ¶
func (*Peer) SetConnectionTimeout ¶
func (*Peer) SetHandshakeTimeout ¶
func (*Peer) WriteP2PMessage ¶
type Proxy ¶
func (*Proxy) ConnectAndStart ¶
func (*Proxy) RegisterHandler ¶
func (*Proxy) RegisterHandlers ¶
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
func (*Relay) RegisterHandler ¶
Click to show internal directories.
Click to hide internal directories.