Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
Connection holds the TCP connection to another node, and it's known protocol magic. The `net.Conn` is guarded by a mutex, to allow both multicast and one-to-one communication between peers.
func NewConnection ¶ added in v0.4.3
func NewConnection(conn net.Conn, gossip *protocol.Gossip) *Connection
NewConnection creates a peer connection struct.
func (*Connection) Addr ¶
func (c *Connection) Addr() string
Addr returns the peer's address as a string.
func (*Connection) ReadMessage ¶
func (c *Connection) ReadMessage() ([]byte, error)
ReadMessage reads from the connection.
type Connector ¶ added in v0.4.3
type Connector struct {
// contains filtered or unexported fields
}
Connector is responsible for accepting incoming connection requests, and establishing outward connections with desired peers.
func NewConnector ¶ added in v0.4.3
func NewConnector(eb eventbus.Broker, gossip *protocol.Gossip, port string, processor *MessageProcessor, services protocol.ServiceFlag, connectFunc connectFunc) *Connector
NewConnector creates a new peer connector, and spawns a goroutine that will accept incoming connection requests on the current address, with the given port.
func (*Connector) Connect ¶ added in v0.4.3
Connect dials a connection with its string, then on succession we pass the connection and the address to the OnConn method.
func (*Connector) GetConnectionsCount ¶ added in v0.4.3
GetConnectionsCount returns the amount of active connections the node has.
type GossipConnector ¶ added in v0.3.0
type GossipConnector struct {
*Connection
}
GossipConnector calls Gossip.Process on the message stream incoming from the ringbuffer. It absolves the function previously carried over by the Gossip preprocessor.
type MessageProcessor ¶ added in v0.4.0
type MessageProcessor struct {
// contains filtered or unexported fields
}
MessageProcessor is connected to all of the processing units that are tied to the peer. It sends an incoming message in the right direction, according to its topic.
func NewMessageProcessor ¶ added in v0.4.0
func NewMessageProcessor(bus eventbus.Broker) *MessageProcessor
NewMessageProcessor returns an initialized MessageProcessor.
func (*MessageProcessor) Collect ¶ added in v0.4.0
func (m *MessageProcessor) Collect(srcPeerID string, packet []byte, respRingBuf *ring.Buffer, services protocol.ServiceFlag, header []byte) ([]bytes.Buffer, error)
Collect a message from the network. The message is unmarshaled and passed down to the processing function.
func (*MessageProcessor) Register ¶ added in v0.4.0
func (m *MessageProcessor) Register(topic topics.Topic, fn ProcessorFunc)
Register a method to a certain topic. This method will be called when a message of the given topic is received.
type ProcessorFunc ¶ added in v0.4.0
ProcessorFunc defines an interface for callbacks which can be registered to the MessageProcessor, in order to process messages from the network.
type Reader ¶
type Reader struct { *Connection // contains filtered or unexported fields }
Reader abstracts all of the logic and fields needed to receive messages from other network nodes.
func (*Reader) Accept ¶
func (p *Reader) Accept(services protocol.ServiceFlag) error
Accept will perform the protocol handshake with the peer.
func (*Reader) Handshake ¶
func (p *Reader) Handshake(services protocol.ServiceFlag) error
Handshake with another peer.
type ReaderFactory ¶ added in v0.4.0
type ReaderFactory struct {
// contains filtered or unexported fields
}
ReaderFactory is responsible for spawning peers. It provides them with the reference to the message processor, which will process the received messages.
func NewReaderFactory ¶ added in v0.4.0
func NewReaderFactory(processor *MessageProcessor) *ReaderFactory
NewReaderFactory returns an initialized ReaderFactory.
func (*ReaderFactory) SpawnReader ¶ added in v0.4.0
func (f *ReaderFactory) SpawnReader(conn *Connection) *Reader
SpawnReader returns a Reader. It will still need to be launched by running ReadLoop in a goroutine.
type VersionMessage ¶
type VersionMessage struct { Version *protocol.Version Timestamp int64 Services protocol.ServiceFlag }
VersionMessage is a version message on the dusk wire protocol.
type Writer ¶
type Writer struct { *Connection // contains filtered or unexported fields }
Writer abstracts all of the logic and fields needed to write messages to other network nodes.
func NewWriter ¶
func NewWriter(conn *Connection, subscriber eventbus.Subscriber, keepAlive ...time.Duration) *Writer
NewWriter returns a Writer. It will still need to be initialized by subscribing to the gossip topic with a stream handler, and by running the WriteLoop in a goroutine.