Documentation ¶
Index ¶
- Constants
- func NewHost(privKey crypto.PrivKey, rconf *config.Config) (host.Host, error)
- func ReadStreamWithBuffer(stream network.Stream) ([]byte, error)
- func WriteStreamWithBuffer(msg []byte, stream network.Stream) error
- type Communication
- type MessageIDSubscriber
- type MessageType
- type StreamManager
- type WrappedMessage
Constants ¶
View Source
const ( LengthHeader = 4 // LengthHeader represent how many bytes we used as header MaxPayload = 20000000 // 20M )
Variables ¶
This section is empty.
Functions ¶
func NewHost ¶
NewHost initiates libp2p host on a given port and configures Noise for the p2p communication.
func ReadStreamWithBuffer ¶
ReadStreamWithBuffer read data from the given stream
Types ¶
type Communication ¶
type Communication interface { Broadcast(peers peer.IDSlice, msg []byte, msgType MessageType, sessionID string) Subscribe(topic MessageType, sessionID string, channel chan *WrappedMessage) UnSubscribe(topic MessageType, sessionID string) }
func NewCommunication ¶
func SetupCommunication ¶
SetupCommunication is a helper method to configure a host, communication and discovery of peers.
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 *WrappedMessage
func (*MessageIDSubscriber) Subscribe ¶
func (ms *MessageIDSubscriber) Subscribe(msgID string, channel chan *WrappedMessage)
func (*MessageIDSubscriber) UnSubscribe ¶
func (ms *MessageIDSubscriber) UnSubscribe(msgID string)
type MessageType ¶
type MessageType uint8
const ( TssKeyGenMsg MessageType = iota TssKeySignMsg TssInitiateMsg TssReadyMsg TssStartMsg Unknown )
func (MessageType) String ¶
func (msgType MessageType) String() string
String implement fmt.Stringer
type StreamManager ¶
type StreamManager struct {
// contains filtered or unexported fields
}
func NewStreamMgr ¶
func NewStreamMgr() *StreamManager
func (*StreamManager) AddStream ¶
func (sm *StreamManager) AddStream(msgID string, stream network.Stream)
func (*StreamManager) ReleaseStream ¶
func (sm *StreamManager) ReleaseStream(msgID string)
type WrappedMessage ¶
type WrappedMessage struct { MessageType MessageType `json:"message_type"` SessionID string `json:"message_id"` Payload []byte `json:"payload"` From peer.ID `json:"from"` }
WrappedMessage is a message sent to the stream iwth Broadcast.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.