Documentation
¶
Index ¶
Constants ¶
View Source
const ( IncomingMessage = 0x1 IncomingStream = 0x2 )
Variables ¶
View Source
var ErrInvalidHandshake = errors.New("invalid handshake")
Functions ¶
func NOPHandshakeFunc ¶
Types ¶
type DefaultDecoder ¶
type DefaultDecoder struct{}
type HandshakeFunc ¶
type RPC ¶
RPC holds any arbitrary data that is being sent over each transports between two nodes in the network.
type TCPPeer ¶
type TCPPeer struct { // The underlying connection of the peer. Which in this case // is a TCP connection net.Conn // contains filtered or unexported fields }
TCPPeer represents the remote node over TCP established connection.
func (*TCPPeer) CloseStream ¶
func (p *TCPPeer) CloseStream()
type TCPTransport ¶
type TCPTransport struct { TCPTransportOpts // contains filtered or unexported fields }
func NewTCPTransport ¶
func NewTCPTransport(opts TCPTransportOpts) *TCPTransport
func (*TCPTransport) Addr ¶
func (t *TCPTransport) Addr() string
Addr implements the Transport interface return the address the transport is accepting connections.
func (*TCPTransport) Close ¶
func (t *TCPTransport) Close() error
Close implements the Transport interface.
func (*TCPTransport) Consume ¶
func (t *TCPTransport) Consume() <-chan RPC
Consume implements the Transport interface, which will return read-only channel for reading the incoming messages received from another peer in the network.
func (*TCPTransport) Dial ¶
func (t *TCPTransport) Dial(addr string) error
Dial Implements Transport Interface
func (*TCPTransport) ListenAndAccept ¶
func (t *TCPTransport) ListenAndAccept() error
type TCPTransportOpts ¶
type TCPTransportOpts struct { ListenAddr string HandshakeFunc HandshakeFunc Decoder Decoder OnPeer func(Peer) error }
Click to show internal directories.
Click to hide internal directories.