messenger

package
v0.0.0-...-7cd50c7 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 23 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckpointMsgHandler func(msg *pb.CheckpointMsg, senderID int32)

Message handlers. These variables hold functions the messenger calls on reception of messages of the corresponding type. Modules using the messenger must assign functions to these variables before the messenger is started (Start())

View Source
var (
	ClientRequestHandler func(msg *pb.ClientRequest)
)
View Source
var Crashed = false

Simulated Crash Flag. It is set true if the peer is supposed to have crashed.

View Source
var OrdererMsgHandler func(msg *pb.ProtocolMessage)
View Source
var StateTransferMsgHandler func(msg *pb.ProtocolMessage)

Functions

func AnnounceBucketAssignment

func AnnounceBucketAssignment(assignment *pb.BucketAssignment)

func ConfigureTLS

func ConfigureTLS(certFile string, keyFile string) *tls.Config

Configures a TLS connection. This function is used for both the client and the server part of the connection. Returns a TLS configuration to be used when creating a network connection (direct or through gRPC).

func Connect

func Connect()

Establishes (in parallel) network connections to all peers in the system. TODO: Deal with errors, e.g. when the connection times out (make sure the RPC call in connectToPeer() has a timeout).

func ConnectToOrderers

func ConnectToOrderers(ownClientID int32, clientLog zerolog.Logger, ordererIDs []int32) (map[int32]pb.Messenger_RequestClient, map[int32]pb.Messenger_BucketsClient, map[int32]*grpc.ClientConn)

Creates connections to all the orderers and returns them as a slice of gRPC client stubs. This function is used by the client.

func EnqueueMsg

func EnqueueMsg(msg *pb.ProtocolMessage, destNodeID int32)

Enqueues a message for sending to a node. Messages are passed by reference, so no modification of a msg must occur after enqueuing. Must not be called concurrently with Connect() to avoid concurrent access to peerConnections map. Unless outgoing messages are buffered (see OutMessageBufSize in the config file), must not be called concurrently with the same destNodeID. If outgoing messages are not buffered and no priority is used (see PriorityConnection in config file), also must not be called concurrently with EnqueuePriorityMessage with the same destNodeID.

func EnqueuePriorityMsg

func EnqueuePriorityMsg(msg *pb.ProtocolMessage, destNodeID int32)

Enqueues a priority message for sending to a node. Messages are passed by reference, so no modification of a msg must occur after enqueuing. Must not be called concurrently with Connect() to avoid concurrent access to peerConnections map. Unless outgoing messages are buffered (see OutMessageBufSize in the config file), must not be called concurrently with the same destNodeID. If outgoing messages are not buffered and no priority is used (see PriorityConnection in config file), also must not be called concurrently with EnqueueMessage with the same destNodeID.

func RespondToClient

func RespondToClient(clientID int32, response *pb.ClientResponse)

Sends a response to a client request.

func Start

func Start(wg *sync.WaitGroup)

Starts the messenger by instantiating a gRPC server that listens to connections from other nodes. Meant to be run as a separate goroutine. Decrements the provided wait group when done.

Types

type BatchedConnection

type BatchedConnection struct {
	// contains filtered or unexported fields
}

func NewBatchedConnection

func NewBatchedConnection(pc PeerConnection, period time.Duration) *BatchedConnection

func (*BatchedConnection) Close

func (bc *BatchedConnection) Close()

func (*BatchedConnection) Send

func (bc *BatchedConnection) Send(msg *pb.ProtocolMessage)

func (*BatchedConnection) SendPriority

func (bc *BatchedConnection) SendPriority(msg *pb.ProtocolMessage)

type BufferedMultiConnection

type BufferedMultiConnection struct {
	// contains filtered or unexported fields
}

func NewBufferedMultiConnection

func NewBufferedMultiConnection(msgSinks []pb.Messenger_ListenClient,
	priorityMsgSinks []pb.Messenger_ListenClient,
	bufSize int) *BufferedMultiConnection

func (*BufferedMultiConnection) Close

func (bmc *BufferedMultiConnection) Close()

func (*BufferedMultiConnection) Send

func (bmc *BufferedMultiConnection) Send(msg *pb.ProtocolMessage)

func (*BufferedMultiConnection) SendPriority

func (bmc *BufferedMultiConnection) SendPriority(msg *pb.ProtocolMessage)

type LockedSimpleConnection

type LockedSimpleConnection struct {
	// contains filtered or unexported fields
}

func NewLockedSimpleConnection

func NewLockedSimpleConnection(msgSink pb.Messenger_ListenClient,
	priorityMsgSink pb.Messenger_ListenClient) *LockedSimpleConnection

func (*LockedSimpleConnection) Close

func (lsc *LockedSimpleConnection) Close()

func (*LockedSimpleConnection) Send

func (lsc *LockedSimpleConnection) Send(msg *pb.ProtocolMessage)

func (*LockedSimpleConnection) SendPriority

func (lsc *LockedSimpleConnection) SendPriority(msg *pb.ProtocolMessage)

type LockingMultiConnection

type LockingMultiConnection struct {
	// contains filtered or unexported fields
}

func NewLockingMultiConnection

func NewLockingMultiConnection(msgSinks []pb.Messenger_ListenClient,
	priorityMsgSinks []pb.Messenger_ListenClient) *LockingMultiConnection

func (*LockingMultiConnection) Close

func (lmc *LockingMultiConnection) Close()

func (*LockingMultiConnection) Send

func (lmc *LockingMultiConnection) Send(msg *pb.ProtocolMessage)

func (*LockingMultiConnection) SendPriority

func (lmc *LockingMultiConnection) SendPriority(msg *pb.ProtocolMessage)

type PeerConnection

type PeerConnection interface {
	Send(msg *pb.ProtocolMessage)
	SendPriority(msg *pb.ProtocolMessage)
	Close()
}

Jump to

Keyboard shortcuts

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