Documentation ¶
Index ¶
- type Connection
- func (c *Connection) Close()
- func (c *Connection) Do(messageType protocols.ProtocolMessageType, data interface{}) error
- func (c *Connection) Handshake() error
- func (c *Connection) PeerID() ([32]byte, error)
- func (c *Connection) ReadOne(timeout time.Duration) (*protocols.Message, error)
- func (c *Connection) ReadSync(handler PeerResponseHandlerFunc) error
- type ConnectionOptionFunc
- type FullNodeProtocol
- type PeerResponseHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a connection with a peer and enables communication
func NewConnection ¶
func NewConnection(ip *net.IP, options ...ConnectionOptionFunc) (*Connection, error)
NewConnection creates a new connection object with the specified peer
func (*Connection) Do ¶
func (c *Connection) Do(messageType protocols.ProtocolMessageType, data interface{}) error
Do send a request over the websocket
func (*Connection) Handshake ¶
func (c *Connection) Handshake() error
Handshake performs the RPC handshake. This should be called before any other method
func (*Connection) PeerID ¶ added in v0.8.2
func (c *Connection) PeerID() ([32]byte, error)
PeerID returns the Peer ID for the remote peer
func (*Connection) ReadSync ¶
func (c *Connection) ReadSync(handler PeerResponseHandlerFunc) error
ReadSync Reads for async responses over the connection in a synchronous fashion, blocking anything else
type ConnectionOptionFunc ¶
type ConnectionOptionFunc func(connection *Connection) error
ConnectionOptionFunc can be used to customize a new Connection
func WithHandshakeTimeout ¶
func WithHandshakeTimeout(timeout time.Duration) ConnectionOptionFunc
WithHandshakeTimeout sets the handshake timeout
func WithNetworkID ¶ added in v0.8.0
func WithNetworkID(networkID string) ConnectionOptionFunc
WithNetworkID sets the network ID for the peer
func WithPeerKeyPair ¶ added in v0.8.0
func WithPeerKeyPair(keypair tls.Certificate) ConnectionOptionFunc
WithPeerKeyPair sets the keypair for the peer
func WithPeerPort ¶ added in v0.8.0
func WithPeerPort(port uint16) ConnectionOptionFunc
WithPeerPort sets the port for the peer
type FullNodeProtocol ¶
type FullNodeProtocol struct {
// contains filtered or unexported fields
}
FullNodeProtocol is for interfacing with full nodes via the peer protocol
func NewFullNodeProtocol ¶
func NewFullNodeProtocol(connection *Connection) (*FullNodeProtocol, error)
NewFullNodeProtocol returns a new instance of the full node protocol
func (*FullNodeProtocol) RequestBlock ¶ added in v0.8.0
func (c *FullNodeProtocol) RequestBlock(data *protocols.RequestBlock) error
RequestBlock asks the current peer to respond with a block
func (*FullNodeProtocol) RequestPeers ¶
func (c *FullNodeProtocol) RequestPeers() error
RequestPeers asks the current peer to respond with their current peer list
type PeerResponseHandlerFunc ¶
PeerResponseHandlerFunc is a function that will be called when a response is returned from a peer