Documentation ¶
Index ¶
- Constants
- Variables
- func LeaderNode(msgID string, blockHeight int64, pIDs []string) (string, error)
- 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)
- func (c *Communication) CancelSubscribe(topic messages.THORChainTSSMessageType, msgID string)
- func (c *Communication) ExportPeerAddress() map[peer.ID]AddrList
- func (c *Communication) GetHost() host.Host
- func (c *Communication) GetLocalPeerID() string
- func (c *Communication) ProcessBroadcast()
- func (c *Communication) ReleaseStream(msgID string)
- func (c *Communication) SetSubscribe(topic messages.THORChainTSSMessageType, msgID string, channel chan *Message)
- func (c *Communication) Start(priKeyBytes []byte) error
- func (c *Communication) Stop() error
- type Config
- type Message
- type MessageIDSubscriber
- type Multiaddr
- type PartyCoordinator
- func (pc *PartyCoordinator) HandleStream(stream network.Stream)
- func (pc *PartyCoordinator) HandleStreamWithLeader(stream network.Stream)
- func (pc *PartyCoordinator) JoinPartyWithLeader(msgID string, blockHeight int64, peers []string, threshold int, ...) ([]peer.ID, string, error)
- func (pc *PartyCoordinator) JoinPartyWithRetry(msgID string, peers []string) ([]peer.ID, error)
- func (pc *PartyCoordinator) ReleaseStream(msgID string)
- func (pc *PartyCoordinator) RemovePeerGroup(messageID string)
- func (pc *PartyCoordinator) StartDiagnostic()
- func (pc *PartyCoordinator) Stop()
- type PeerStatus
- type ResourceMetricReporter
- func (rmr *ResourceMetricReporter) AllowConn(dir network.Direction, usefd bool)
- func (rmr *ResourceMetricReporter) AllowMemory(size int)
- func (rmr *ResourceMetricReporter) AllowPeer(p peer.ID)
- func (rmr *ResourceMetricReporter) AllowProtocol(proto protocol.ID)
- func (rmr *ResourceMetricReporter) AllowService(svc string)
- func (rmr *ResourceMetricReporter) AllowStream(p peer.ID, dir network.Direction)
- func (rmr *ResourceMetricReporter) BlockConn(dir network.Direction, usefd bool)
- func (rmr *ResourceMetricReporter) BlockMemory(size int)
- func (rmr *ResourceMetricReporter) BlockPeer(p peer.ID)
- func (rmr *ResourceMetricReporter) BlockProtocol(proto protocol.ID)
- func (rmr *ResourceMetricReporter) BlockProtocolPeer(proto protocol.ID, p peer.ID)
- func (rmr *ResourceMetricReporter) BlockService(svc string)
- func (rmr *ResourceMetricReporter) BlockServicePeer(svc string, p peer.ID)
- func (rmr *ResourceMetricReporter) BlockStream(p peer.ID, dir network.Direction)
- type StreamMgr
Constants ¶
const ( LengthHeader = 4 // LengthHeader represent how many bytes we used as header TimeoutReadPayload = time.Second * 10 TimeoutWritePayload = time.Second * 10 MaxPayload = 20000000 // 20M )
const ( // TimeoutConnecting maximum time for wait for peers to connect TimeoutConnecting = time.Second * 20 )
Variables ¶
var ( ErrJoinPartyTimeout = errors.New("fail to join party, timeout") ErrLeaderNotReady = errors.New("leader not reachable") ErrSignReceived = errors.New("signature received") ErrNotActiveSigner = errors.New("not active signer") ErrSigGenerated = errors.New("signature generated") )
var ApplyDeadline = true
applyDeadline will be true , and only disable it when we are doing test the reason being the p2p network , mocknet, mock stream doesn't support SetReadDeadline ,SetWriteDeadline feature
var TSSProtocolID protocol.ID = "/p2p/tss"
TSSProtocolID protocol id used for tss
Functions ¶
func LeaderNode ¶
LeaderNode use the given input buf to calculate a hash , and consistently choose a node as a master coordinate note
func ReadStreamWithBuffer ¶
ReadStreamWithBuffer read data from the given stream
Types ¶
type Communication ¶
type Communication struct { BroadcastMsgChan chan *messages.BroadcastMsgChan // contains filtered or unexported fields }
Communication use p2p to broadcast messages among all the TSS nodes
func NewCommunication ¶
func NewCommunication(rendezvous string, bootstrapPeers []Multiaddr, port int, externalIP string) (*Communication, error)
NewCommunication create a new instance of Communication
func (*Communication) Broadcast ¶
func (c *Communication) Broadcast(peers []peer.ID, msg []byte, msgID string)
Broadcast message to Peers
func (*Communication) CancelSubscribe ¶
func (c *Communication) CancelSubscribe(topic messages.THORChainTSSMessageType, 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) ProcessBroadcast ¶
func (c *Communication) ProcessBroadcast()
func (*Communication) ReleaseStream ¶
func (c *Communication) ReleaseStream(msgID string)
func (*Communication) SetSubscribe ¶
func (c *Communication) SetSubscribe(topic messages.THORChainTSSMessageType, msgID string, channel chan *Message)
func (*Communication) Start ¶
func (c *Communication) Start(priKeyBytes []byte) error
Start will start the communication
type MessageIDSubscriber ¶
type MessageIDSubscriber struct {
// contains filtered or unexported fields
}
MessageIDSubscriber
func NewMessageIDSubscriber ¶
func NewMessageIDSubscriber() *MessageIDSubscriber
NewMessageIDSubscriber create a new instance of 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 PartyCoordinator ¶
type PartyCoordinator struct {
// contains filtered or unexported fields
}
func NewPartyCoordinator ¶
func NewPartyCoordinator(host host.Host, timeout time.Duration) *PartyCoordinator
NewPartyCoordinator create a new instance of PartyCoordinator
func (*PartyCoordinator) HandleStream ¶
func (pc *PartyCoordinator) HandleStream(stream network.Stream)
func (*PartyCoordinator) HandleStreamWithLeader ¶
func (pc *PartyCoordinator) HandleStreamWithLeader(stream network.Stream)
HandleStream handle party coordinate stream
func (*PartyCoordinator) JoinPartyWithLeader ¶
func (*PartyCoordinator) JoinPartyWithRetry ¶
JoinPartyWithRetry this method provide the functionality to join party with retry and back off
func (*PartyCoordinator) ReleaseStream ¶
func (pc *PartyCoordinator) ReleaseStream(msgID string)
func (*PartyCoordinator) RemovePeerGroup ¶
func (pc *PartyCoordinator) RemovePeerGroup(messageID string)
func (*PartyCoordinator) StartDiagnostic ¶
func (pc *PartyCoordinator) StartDiagnostic()
type PeerStatus ¶
type PeerStatus struct {
// contains filtered or unexported fields
}
func NewPeerStatus ¶
type ResourceMetricReporter ¶
type ResourceMetricReporter struct {
// contains filtered or unexported fields
}
func NewResourceMetricReporter ¶
func NewResourceMetricReporter() *ResourceMetricReporter
func (*ResourceMetricReporter) AllowConn ¶
func (rmr *ResourceMetricReporter) AllowConn(dir network.Direction, usefd bool)
AllowConn is invoked when opening a connection is allowed
func (*ResourceMetricReporter) AllowMemory ¶
func (rmr *ResourceMetricReporter) AllowMemory(size int)
AllowMemory is invoked when a memory reservation is allowed
func (*ResourceMetricReporter) AllowPeer ¶
func (rmr *ResourceMetricReporter) AllowPeer(p peer.ID)
AllowPeer is invoked when attaching ac onnection to a peer is allowed
func (*ResourceMetricReporter) AllowProtocol ¶
func (rmr *ResourceMetricReporter) AllowProtocol(proto protocol.ID)
AllowProtocol is invoked when setting the protocol for a stream is allowed
func (*ResourceMetricReporter) AllowService ¶
func (rmr *ResourceMetricReporter) AllowService(svc string)
AllowService is invoked when setting the protocol for a stream is allowed
func (*ResourceMetricReporter) AllowStream ¶
func (rmr *ResourceMetricReporter) AllowStream(p peer.ID, dir network.Direction)
AllowStream is invoked when opening a stream is allowed
func (*ResourceMetricReporter) BlockConn ¶
func (rmr *ResourceMetricReporter) BlockConn(dir network.Direction, usefd bool)
BlockConn is invoked when opening a connection is blocked
func (*ResourceMetricReporter) BlockMemory ¶
func (rmr *ResourceMetricReporter) BlockMemory(size int)
BlockMemory is invoked when a memory reservation is blocked
func (*ResourceMetricReporter) BlockPeer ¶
func (rmr *ResourceMetricReporter) BlockPeer(p peer.ID)
BlockPeer is invoked when attaching a connection to a peer is blocked
func (*ResourceMetricReporter) BlockProtocol ¶
func (rmr *ResourceMetricReporter) BlockProtocol(proto protocol.ID)
BlockProtocol is invoked when setting the protocol for a stream is blocked
func (*ResourceMetricReporter) BlockProtocolPeer ¶
func (rmr *ResourceMetricReporter) BlockProtocolPeer(proto protocol.ID, p peer.ID)
BlockProtocolPeer is invoked when setting the protocol for a stream is blocked at the per protocol peer scope
func (*ResourceMetricReporter) BlockService ¶
func (rmr *ResourceMetricReporter) BlockService(svc string)
BlockService is invoked when setting the protocol for a stream is blocked
func (*ResourceMetricReporter) BlockServicePeer ¶
func (rmr *ResourceMetricReporter) BlockServicePeer(svc string, p peer.ID)
BlockServicePeer is invoked when setting the service for a stream is blocked at the per service peer scope
func (*ResourceMetricReporter) BlockStream ¶
func (rmr *ResourceMetricReporter) BlockStream(p peer.ID, dir network.Direction)
BlockStream is invoked when opening a stream is blocked
type StreamMgr ¶
type StreamMgr struct {
// contains filtered or unexported fields
}
func NewStreamMgr ¶
func NewStreamMgr() *StreamMgr