Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶ added in v0.4.0
func Create(ctx context.Context, reader *Reader, writer *Writer, writeQueueChan <-chan bytes.Buffer) error
Create two-way communication with a peer. This function will allow both goroutines to run as long as no errors are encountered. Once the first error comes through, the context is canceled, and both goroutines are cleaned up.
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 (*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 GossipConnector ¶ added in v0.3.0
type GossipConnector struct {
*Connection
// contains filtered or unexported fields
}
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) CanRoute ¶ added in v0.4.0
func (m *MessageProcessor) CanRoute(topic topics.Topic) bool
CanRoute determines whether or not a message needs to be filtered by the dupemap. TODO: rename.
func (*MessageProcessor) Collect ¶ added in v0.4.0
func (m *MessageProcessor) Collect(srcPeerID string, packet []byte, respChan chan<- 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.
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 net.Conn, gossip *protocol.Gossip, responseChan chan<- bytes.Buffer) *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 net.Conn, gossip *protocol.Gossip, 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.