p2p

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoggerHandler = HandlerFunc(func(msg PostProcessable) {
	data, error := json.Marshal(msg)
	if error != nil {
		fmt.Println("logger plugin err: ", error)
		return
	}

	fmt.Println("logger - message : ", string(data))
})

LoggerHandler logs the messages back and forth.

View Source
var StringLoggerHandler = HandlerFunc(func(msg PostProcessable) {
	fmt.Printf("Received message %T\n", msg.P2PMessageEnvelope.P2PMessage)
})

StringLoggerHandler simply prints the messages as they go through the client.

Functions

func DecodeHex

func DecodeHex(hexString string) (data []byte)

Types

type Client

type Client struct {
	API            *eos.API
	ChainID        eos.SHA256Bytes
	NetworkVersion int16
	Conn           net.Conn
	NodeID         eos.SHA256Bytes
	// contains filtered or unexported fields
}

func NewClient

func NewClient(p2pAddr string, eosAPI *eos.API, chainID eos.SHA256Bytes, networkVersion int16) *Client

func (*Client) Connect

func (c *Client) Connect() (err error)

func (*Client) RegisterHandler

func (c *Client) RegisterHandler(h Handler)

func (*Client) SendHandshake

func (c *Client) SendHandshake(info handshakeInfo) (err error)

func (*Client) SendSyncRequest

func (c *Client) SendSyncRequest(startBlockNum uint32, endBlockNumber uint32) (err error)

func (*Client) UnregisterHandler

func (c *Client) UnregisterHandler(h Handler)

type Handler

type Handler interface {
	Handle(msg PostProcessable)
}

type HandlerFunc

type HandlerFunc func(msg PostProcessable)

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(msg PostProcessable)

type PostProcessable

type PostProcessable struct {
	Route              *Route                  `json:"route"`
	P2PMessageEnvelope *eos.P2PMessageEnvelope `json:"p2p_message_envelope"`
}

type Proxy

type Proxy struct {
	Routes   []*Route
	Handlers []Handler
}

func (*Proxy) Start

func (p *Proxy) Start()

type Route

type Route struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Jump to

Keyboard shortcuts

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