Documentation
¶
Index ¶
- Constants
- Variables
- func ReadStreamWithBuffer(stream network.Stream) ([]byte, error)
- func WriteStreamWithBuffer(msg []byte, stream network.Stream) error
- type AddrList
- type Communication
- func (c *Communication) Broadcast(peers []peer.ID, msg []byte, msgID string, needHandleResponse bool)
- func (c *Communication) CancelSubscribe(topic messages.TSSMessageTpe, msgID string)
- func (c *Communication) ExportPeerAddress() map[peer.ID]AddrList
- func (c *Communication) GetHost() host.Host
- func (c *Communication) GetLocalPeerID() string
- func (c *Communication) HandleResponse(stream network.Stream, remotePeer peer.ID) error
- func (c *Communication) ProcessBroadcast()
- func (c *Communication) ReleaseStream(msgID string)
- func (c *Communication) SetSubscribe(topic messages.TSSMessageTpe, msgID string, channel chan *Message)
- func (c *Communication) Start(priKeyBytes []byte) error
- func (c *Communication) Stop() error
- func (c *Communication) VerifyPeerId(peerId string) bool
- type Config
- type Message
- type MessageIDSubscriber
- type StreamMgr
Constants ¶
View Source
const ( LengthHeader = 4 // LengthHeader represent how many bytes we used as header TimeoutReadPayload = time.Second * 10 TimeoutWritePayload = time.Second * 10 MaxPayload = 20000000 // 20M )
View Source
const ( // TimeoutConnecting maximum time for wait for peers to connect TimeoutConnecting = time.Second * 20 )
Variables ¶
View Source
var ApplyDeadline = true
View Source
var TSSProtocolID protocol.ID = "/p2p/tss"
TSSProtocolID protocol id used for tss
Functions ¶
func ReadStreamWithBuffer ¶
ReadStreamWithBuffer read data from the given stream
Types ¶
type Communication ¶
type Communication struct { BroadcastMsgChan chan *messages.BroadcastMsgChan // contains filtered or unexported fields }
func NewCommunication ¶
func NewCommunication(bootstrapPeers []maddr.Multiaddr, port int, externalIP string, waitFullConnected bool, store types.TssMemberStore) (*Communication, error)
func (*Communication) Broadcast ¶
func (c *Communication) Broadcast(peers []peer.ID, msg []byte, msgID string, needHandleResponse bool)
Broadcast message to Peers
func (*Communication) CancelSubscribe ¶
func (c *Communication) CancelSubscribe(topic messages.TSSMessageTpe, msgID string)
func (*Communication) ExportPeerAddress ¶
func (c *Communication) ExportPeerAddress() map[peer.ID]AddrList
func (*Communication) GetLocalPeerID ¶
func (c *Communication) GetLocalPeerID() string
GetLocalPeerID from p2p host
func (*Communication) HandleResponse ¶
func (*Communication) ProcessBroadcast ¶
func (c *Communication) ProcessBroadcast()
func (*Communication) ReleaseStream ¶
func (c *Communication) ReleaseStream(msgID string)
func (*Communication) SetSubscribe ¶
func (c *Communication) SetSubscribe(topic messages.TSSMessageTpe, msgID string, channel chan *Message)
func (*Communication) Start ¶
func (c *Communication) Start(priKeyBytes []byte) error
Start will start the communication
func (*Communication) VerifyPeerId ¶
func (c *Communication) VerifyPeerId(peerId string) bool
type MessageIDSubscriber ¶
type MessageIDSubscriber struct {
// contains filtered or unexported fields
}
func NewMessageIDSubscriber ¶
func NewMessageIDSubscriber() *MessageIDSubscriber
func (*MessageIDSubscriber) GetSubscriber ¶
func (ms *MessageIDSubscriber) GetSubscriber(msgID string) chan *Message
GetSubscribers return a subscriber of given message id
func (*MessageIDSubscriber) IsEmpty ¶
func (ms *MessageIDSubscriber) IsEmpty() bool
IsEmpty check whether there is subscribers
func (*MessageIDSubscriber) Subscribe ¶
func (ms *MessageIDSubscriber) Subscribe(msgID string, channel chan *Message)
Subscribe a message id
func (*MessageIDSubscriber) UnSubscribe ¶
func (ms *MessageIDSubscriber) UnSubscribe(msgID string)
UnSubscribe a messageid
type StreamMgr ¶
type StreamMgr struct {
// contains filtered or unexported fields
}
func NewStreamMgr ¶
func NewStreamMgr() *StreamMgr
func (*StreamMgr) ReleaseStream ¶
Click to show internal directories.
Click to hide internal directories.