Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyDeadline(stream network.Stream, timeout time.Duration, readOrWrite bool) error
- func GetFreePorts(n int) ([]int, error)
- func PickLeader(msgID string, blockHeight int64, peers []peer.ID) (peer.ID, error)
- func ReadStreamWithBuffer(stream network.Stream) ([]byte, error)
- func WriteStreamWithBuffer(msg []byte, stream network.Stream) error
- 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][]maddr.Multiaddr
- func (c *Communication) FreeStreams(msgID string)
- func (c *Communication) GetHost() host.Host
- func (c *Communication) GetLocalPeerID() string
- func (c *Communication) ProcessBroadcast()
- 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 PartyCoordinator
- func (pc *PartyCoordinator) FreeStreams(msgID string)
- func (pc *PartyCoordinator) HandleStreamWithLeader(stream network.Stream)
- func (pc *PartyCoordinator) JoinPartyWithLeader(msgID string, blockHeight int64, peers []peer.ID, threshold int, ...) ([]peer.ID, peer.ID, error)
- func (pc *PartyCoordinator) RemovePeerGroup(messageID string)
- func (pc *PartyCoordinator) Stop()
- type ResourceMetricReporter
- func (rmr *ResourceMetricReporter) AllowConn(_ network.Direction, _ bool)
- func (rmr *ResourceMetricReporter) AllowMemory(_ int)
- func (rmr *ResourceMetricReporter) AllowPeer(_ peer.ID)
- func (rmr *ResourceMetricReporter) AllowProtocol(_ protocol.ID)
- func (rmr *ResourceMetricReporter) AllowService(_ string)
- func (rmr *ResourceMetricReporter) AllowStream(_ peer.ID, _ 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 StreamManager
- type WhitelistConnectionGater
- func (wg *WhitelistConnectionGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
- func (wg *WhitelistConnectionGater) InterceptAddrDial(p peer.ID, m maddr.Multiaddr) (allow bool)
- func (wg *WhitelistConnectionGater) InterceptPeerDial(p peer.ID) (allow bool)
- func (wg *WhitelistConnectionGater) InterceptSecured(_ network.Direction, p peer.ID, m network.ConnMultiaddrs) (allow bool)
- func (wg *WhitelistConnectionGater) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)
Constants ¶
const ( // PayloadHeaderLen we use first 4 bytes (uint32) // to indicate the payload size over the wire. PayloadHeaderLen = 4 // similar to TCP "ack" ResponseMessage = "done" ResponseMessageBytesLen = 4 )
const NotificationSigReceived = "signature received"
const ProtocolJoinPartyWithLeader protocol.ID = "/p2p/join-party-leader"
ProtocolJoinPartyWithLeader "party with leader" is an entity that is responsible for picking a leader for signing a single msg_id and coordinating/propagating signature data across the "party". The leader is picked based on message data; see LeaderNode().
const ProtocolSignatureNotifier protocol.ID = "/p2p/signatureNotifier"
ProtocolSignatureNotifier is the protocol for notifying peers for signature data. Each peer is responsible for signature verification.
const ProtocolTSS protocol.ID = "/p2p/tss"
ProtocolTSS is the protocol for responsible for passing lib-tss messages across peers and performing keysign/keygen ceremonies.
Variables ¶
Functions ¶
func ApplyDeadline ¶
ApplyDeadline applies read/write (read=true, write=false) deadline to the stream. Tolerates mocknet errors. Resets the stream on failure.
func GetFreePorts ¶
GetFreePorts allocated N available ports for testing purposes See https://github.com/tendermint/tendermint/issues/3682
func PickLeader ¶
PickLeader picks party leader based on provided input The logic is preserved as in the original implementation.
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( bootstrapPeers []maddr.Multiaddr, port int, externalIP string, whitelistedPeers []peer.ID, logger zerolog.Logger, ) (*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][]maddr.Multiaddr
func (*Communication) FreeStreams ¶
func (c *Communication) FreeStreams(msgID string)
func (*Communication) GetLocalPeerID ¶
func (c *Communication) GetLocalPeerID() string
GetLocalPeerID from p2p host
func (*Communication) ProcessBroadcast ¶
func (c *Communication) ProcessBroadcast()
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, logger zerolog.Logger) *PartyCoordinator
NewPartyCoordinator create a new instance of PartyCoordinator
func (*PartyCoordinator) FreeStreams ¶
func (pc *PartyCoordinator) FreeStreams(msgID string)
func (*PartyCoordinator) HandleStreamWithLeader ¶
func (pc *PartyCoordinator) HandleStreamWithLeader(stream network.Stream)
HandleStream handle party coordinate stream
func (*PartyCoordinator) JoinPartyWithLeader ¶
func (*PartyCoordinator) RemovePeerGroup ¶
func (pc *PartyCoordinator) RemovePeerGroup(messageID string)
type ResourceMetricReporter ¶
type ResourceMetricReporter struct {
// contains filtered or unexported fields
}
func NewResourceMetricReporter ¶
func NewResourceMetricReporter(logger zerolog.Logger) *ResourceMetricReporter
func (*ResourceMetricReporter) AllowConn ¶
func (rmr *ResourceMetricReporter) AllowConn(_ network.Direction, _ bool)
AllowConn is invoked when opening a connection is allowed
func (*ResourceMetricReporter) AllowMemory ¶
func (rmr *ResourceMetricReporter) AllowMemory(_ int)
AllowMemory is invoked when a memory reservation is allowed
func (*ResourceMetricReporter) AllowPeer ¶
func (rmr *ResourceMetricReporter) AllowPeer(_ peer.ID)
AllowPeer is invoked when attaching ac connection to a peer is allowed
func (*ResourceMetricReporter) AllowProtocol ¶
func (rmr *ResourceMetricReporter) AllowProtocol(_ protocol.ID)
AllowProtocol is invoked when setting the protocol for a stream is allowed
func (*ResourceMetricReporter) AllowService ¶
func (rmr *ResourceMetricReporter) AllowService(_ string)
AllowService is invoked when setting the protocol for a stream is allowed
func (*ResourceMetricReporter) AllowStream ¶
func (rmr *ResourceMetricReporter) AllowStream(_ peer.ID, _ 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 StreamManager ¶
type StreamManager struct {
// contains filtered or unexported fields
}
StreamManager is responsible fro libp2p stream bookkeeping. It can store streams by message id for latter release as we can't have thousands of streams opened at the same time.
Currently, it's not a manager, but more a "garbage collector" for streams. It also runs a cleanup routine to remove UNUSED && STALE streams.
func NewStreamManager ¶
func NewStreamManager(logger zerolog.Logger, maxAgeBeforeCleanup time.Duration) *StreamManager
NewStreamManager StreamManager constructor.
func (*StreamManager) Free ¶
func (sm *StreamManager) Free(msgID string)
Free synchronously releases all streams by the given message id.
func (*StreamManager) ResetStream ¶
func (sm *StreamManager) ResetStream(msgID string, stream network.Stream) bool
ResetStream resets given stream and logs the error if it fails. This is just a helper function to avoid error & logging handling. It doesn't add the stream to the manager.
func (*StreamManager) Stash ¶
func (sm *StreamManager) Stash(msgID string, stream network.Stream)
Stash adds a stream to the manager for later release.
func (*StreamManager) StashUnknown ¶
func (sm *StreamManager) StashUnknown(stream network.Stream)
StashUnknown adds an unknown stream to the manager for later release.
type WhitelistConnectionGater ¶
type WhitelistConnectionGater struct {
// contains filtered or unexported fields
}
func NewWhitelistConnectionGater ¶
func NewWhitelistConnectionGater(whitelistedPeers []peer.ID, logger zerolog.Logger) *WhitelistConnectionGater
func (*WhitelistConnectionGater) InterceptAccept ¶
func (wg *WhitelistConnectionGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
func (*WhitelistConnectionGater) InterceptAddrDial ¶
func (*WhitelistConnectionGater) InterceptPeerDial ¶
func (wg *WhitelistConnectionGater) InterceptPeerDial(p peer.ID) (allow bool)
func (*WhitelistConnectionGater) InterceptSecured ¶
func (wg *WhitelistConnectionGater) InterceptSecured( _ network.Direction, p peer.ID, m network.ConnMultiaddrs, ) (allow bool)
func (*WhitelistConnectionGater) InterceptUpgraded ¶
func (wg *WhitelistConnectionGater) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)