comm

package
v0.0.0-...-fbe82ab Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCertificatesOrPanic

func GenerateCertificatesOrPanic() tls.Certificate

GenerateCertificateSorpanic生成一对随机的公钥和私钥 并返回TLS证书

func SetDialTimeout

func SetDialTimeout(timeout time.Duration)

setDialTimeout设置拨号超时

Types

type AggregatedSendResult

type AggregatedSendResult []SendResult

AggregatedSendResult表示一个sendResults切片

func (AggregatedSendResult) AckCount

func (ar AggregatedSendResult) AckCount() int

AckCount返回成功确认的次数

func (AggregatedSendResult) NackCount

func (ar AggregatedSendResult) NackCount() int

nackcount返回未成功确认的数目

func (AggregatedSendResult) String

func (ar AggregatedSendResult) String() string

字符串返回JSED字符串表示形式 聚合发送结果的

type ChannelDeMultiplexer

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

ChannelDisultiplexer是一个可以接收通道注册(addChannel)的结构。 和出版物(解编),并将出版物广播给登记处。 根据其谓词

func NewChannelDemultiplexer

func NewChannelDemultiplexer() *ChannelDeMultiplexer

新建信道解复用器创建新信道解复用器

func (*ChannelDeMultiplexer) AddChannel

func (m *ChannelDeMultiplexer) AddChannel(predicate common.MessageAcceptor) chan interface{}

addchannel用某个谓词注册一个通道

func (*ChannelDeMultiplexer) Close

func (m *ChannelDeMultiplexer) Close()

关闭关闭此频道,使所有频道在之前注册 也可以关闭。

func (*ChannelDeMultiplexer) DeMultiplex

func (m *ChannelDeMultiplexer) DeMultiplex(msg interface{})

解复用将消息广播到返回的所有通道 通过addchannel调用并保存受尊重的谓词。

type Comm

type Comm interface {

	//getpkiid返回此实例的pki id
	GetPKIid() common.PKIidType

	//发送向远程对等发送消息
	Send(msg *proto.SignedGossipMessage, peers ...*RemotePeer)

	//sendwithack向远程对等端发送消息,等待来自它们的minack的确认,或者直到某个超时结束。
	SendWithAck(msg *proto.SignedGossipMessage, timeout time.Duration, minAck int, peers ...*RemotePeer) AggregatedSendResult

	//Probe探测一个远程节点,如果响应为零,则返回nil。
	//如果不是的话也会出错。
	Probe(peer *RemotePeer) error

	//握手验证远程对等机并返回
	//(其身份,无)成功和(无,错误)
	Handshake(peer *RemotePeer) (api.PeerIdentityType, error)

	//accept返回与某个谓词匹配的其他节点发送的消息的专用只读通道。
	//来自通道的每条消息都可用于向发送者发送回复。
	Accept(common.MessageAcceptor) <-chan proto.ReceivedMessage

	//ExpertedHead返回怀疑处于脱机状态的节点终结点的只读通道
	PresumedDead() <-chan common.PKIidType

	//closeconn关闭到某个端点的连接
	CloseConn(peer *RemotePeer)

	//停止停止模块
	Stop()
}

comm是一个能够与其他对等方通信的对象。 它还嵌入了一个通信模块。

func NewCommInstance

func NewCommInstance(s *grpc.Server, certs *common.TLSCertificates, idStore identity.Mapper,
	peerIdentity api.PeerIdentityType, secureDialOpts api.PeerSecureDialOpts, sa api.SecurityAdvisor,
	dialOpts ...grpc.DialOption) (Comm, error)

new comm instance创建一个新的comm实例,该实例将自身绑定到给定的grpc服务器。

func NewCommInstanceWithServer

func NewCommInstanceWithServer(port int, idMapper identity.Mapper, peerIdentity api.PeerIdentityType,
	secureDialOpts api.PeerSecureDialOpts, sa api.SecurityAdvisor, dialOpts ...grpc.DialOption) (Comm, error)

NewcomInstanceWithServer创建一个创建底层GRPC服务器的通信实例

type ReceivedMessageImpl

type ReceivedMessageImpl struct {
	*proto.SignedGossipMessage
	// contains filtered or unexported fields
}

ReceivedMessageImpl是ReceivedMessage的实现

func (*ReceivedMessageImpl) Ack

func (m *ReceivedMessageImpl) Ack(err error)

ACK向发送方返回消息确认

func (*ReceivedMessageImpl) GetConnectionInfo

func (m *ReceivedMessageImpl) GetConnectionInfo() *proto.ConnectionInfo

getConnectionInfo返回有关远程对等机的信息 发出信息

func (*ReceivedMessageImpl) GetGossipMessage

func (m *ReceivedMessageImpl) GetGossipMessage() *proto.SignedGossipMessage

GetGossipMessage返回内部GossipMessage

func (*ReceivedMessageImpl) GetSourceEnvelope

func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope

GetSourceEnvelope返回接收到的消息所在的信封 建筑用

func (*ReceivedMessageImpl) Respond

func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage)

Respond sends a msg to the source that sent the ReceivedMessageImpl

type RemotePeer

type RemotePeer struct {
	Endpoint string
	PKIID    common.PKIidType
}

远程对等定义对等端的端点及其pkiid

func (*RemotePeer) String

func (p *RemotePeer) String() string

字符串将远程对等机转换为字符串

type SecurityAdvisor

type SecurityAdvisor interface {
	//orgByPeerIdentity返回给定PeerIdentityType的组织标识
	OrgByPeerIdentity(api.PeerIdentityType) api.OrgIdentityType
}

SecurityAdvisor定义外部辅助对象 提供安全和身份相关功能

type SendResult

type SendResult struct {
	RemotePeer
	// contains filtered or unexported fields
}

sendResult定义发送到远程对等机的结果

func (SendResult) Error

func (sr SendResult) Error() string

错误返回sendResult的错误或空字符串 如果没有发生错误

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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