{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package comm\n\n## Constants\n\n```go\nconst (\n\tDefDialTimeout  = time.Second * 3\n\tDefConnTimeout  = time.Second * 2\n\tDefRecvBuffSize = 20\n\tDefSendBuffSize = 20\n)\n```\n\n## Functions\n\n```go\nfunc GenerateCertificatesOrPanic() tls.Certificate\n```\nGenerateCertificatesOrPanic generates a a random pair of public and private keys and return TLS certificate\n\n## Types\n\n```go\ntype AggregatedSendResult []SendResult\n```\nAggregatedSendResult represents a slice of SendResults\n\n```go\nfunc (ar AggregatedSendResult) AckCount() int\n```\nAckCount returns the number of successful acknowledgements\n\n```go\nfunc (ar AggregatedSendResult) NackCount() int\n```\nNackCount returns the number of unsuccessful acknowledgements\n\n```go\nfunc (ar AggregatedSendResult) String() string\n```\nString returns a JSONed string representation of the AggregatedSendResult\n\n```go\ntype ChannelDeMultiplexer struct {\n\t// contains filtered or unexported fields\n}\n```\nChannelDeMultiplexer is a struct that can receive channel registrations (AddChannel) and publications (DeMultiplex) and it broadcasts the publications to registrations according to their predicate\n\n```go\nfunc NewChannelDemultiplexer() *ChannelDeMultiplexer\n```\nNewChannelDemultiplexer creates a new ChannelDeMultiplexer\n\n```go\nfunc (m *ChannelDeMultiplexer) AddChannel(predicate common.MessageAcceptor) chan interface{}\n```\nAddChannel registers a channel with a certain predicate\n\n```go\nfunc (m *ChannelDeMultiplexer) Close()\n```\nClose closes this channel, which makes all channels registered before to close as well.\n\n```go\nfunc (m *ChannelDeMultiplexer) DeMultiplex(msg interface{})\n```\nDeMultiplex broadcasts the message to all channels that were returned by AddChannel calls and that hold the respected predicates.\n\n```go\ntype Comm interface {\n\n\t// GetPKIid returns this instance's PKI id\n\tGetPKIid() common.PKIidType\n\n\t// Send sends a message to remote peers\n\tSend(msg *proto.SignedGossipMessage, peers ...*RemotePeer)\n\n\t// SendWithAck sends a message to remote peers, waiting for acknowledgement from minAck of them, or until a certain timeout expires\n\tSendWithAck(msg *proto.SignedGossipMessage, timeout time.Duration, minAck int, peers ...*RemotePeer) AggregatedSendResult\n\n\t// Probe probes a remote node and returns nil if its responsive,\n\t// and an error if it's not.\n\tProbe(peer *RemotePeer) error\n\n\t// Handshake authenticates a remote peer and returns\n\t// (its identity, nil) on success and (nil, error)\n\tHandshake(peer *RemotePeer) (api.PeerIdentityType, error)\n\n\t// Accept returns a dedicated read-only channel for messages sent by other nodes that match a certain predicate.\n\t// Each message from the channel can be used to send a reply back to the sender\n\tAccept(common.MessageAcceptor) \u003c-chan proto.ReceivedMessage\n\n\t// PresumedDead returns a read-only channel for node endpoints that are suspected to be offline\n\tPresumedDead() \u003c-chan common.PKIidType\n\n\t// IdentitySwitch returns a read-only channel about identity change events\n\tIdentitySwitch() \u003c-chan common.PKIidType\n\n\t// CloseConn closes a connection to a certain endpoint\n\tCloseConn(peer *RemotePeer)\n\n\t// Stop stops the module\n\tStop()\n}\n```\nComm is an object that enables to communicate with other peers that also embed a CommModule.\n\n```go\nfunc NewCommInstance(s *grpc.Server, certs *common.TLSCertificates, idStore identity.Mapper,\n\tpeerIdentity api.PeerIdentityType, secureDialOpts api.PeerSecureDialOpts, sa api.SecurityAdvisor,\n\tcommMetrics *metrics.CommMetrics, config CommConfig, dialOpts ...grpc.DialOption) (Comm, error)\n```\nNewCommInstance creates a new comm instance that binds itself to the given gRPC server\n\n```go\ntype CommConfig struct {\n\tDialTimeout  time.Duration // Dial timeout\n\tConnTimeout  time.Duration // Connection timeout\n\tRecvBuffSize int           // Buffer size of received messages\n\tSendBuffSize int           // Buffer size of sending messages\n}\n```\nCommConfig is the configuration required to initialize a new comm\n\n```go\ntype ConnConfig struct {\n\tRecvBuffSize int\n\tSendBuffSize int\n}\n```\nConnConfig is the configuration required to initialize a new conn\n\n```go\ntype ReceivedMessageImpl struct {\n\t*proto.SignedGossipMessage\n\t// contains filtered or unexported fields\n}\n```\nReceivedMessageImpl is an implementation of ReceivedMessage\n\n```go\nfunc (m *ReceivedMessageImpl) Ack(err error)\n```\nAck returns to the sender an acknowledgement for the message\n\n```go\nfunc (m *ReceivedMessageImpl) GetConnectionInfo() *proto.ConnectionInfo\n```\nGetConnectionInfo returns information about the remote peer that send the message\n\n```go\nfunc (m *ReceivedMessageImpl) GetGossipMessage() *proto.SignedGossipMessage\n```\nGetGossipMessage returns the inner GossipMessage\n\n```go\nfunc (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope\n```\nGetSourceEnvelope Returns the Envelope the ReceivedMessage was constructed with\n\n```go\nfunc (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage)\n```\nRespond sends a msg to the source that sent the ReceivedMessageImpl\n\n```go\ntype RemotePeer struct {\n\tEndpoint string\n\tPKIID    common.PKIidType\n}\n```\nRemotePeer defines a peer's endpoint and its PKIid\n\n```go\nfunc (p *RemotePeer) String() string\n```\nString converts a RemotePeer to a string\n\n```go\ntype SecurityAdvisor interface {\n\t// OrgByPeerIdentity returns the organization identity of the given PeerIdentityType\n\tOrgByPeerIdentity(api.PeerIdentityType) api.OrgIdentityType\n}\n```\nSecurityAdvisor defines an external auxiliary object that provides security and identity related capabilities\n\n```go\ntype SendResult struct {\n\tRemotePeer\n\t// contains filtered or unexported fields\n}\n```\nSendResult defines a result of a send to a remote peer\n\n```go\nfunc (sr SendResult) Error() string\n```\nError returns the error of the SendResult, or an empty string if an error hasn't occurred\n\n","path":"github.com/eric-erki/https-hyperledger.org/gossip/comm","name":"comm","synopsis":"","isRedistributable":true}
