comm

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignatureSessionID      = "signatures"
	AcrossSessionID         = "across"
	SprinterCreditSessionID = "sprinter-credit"
	LifiEscrowSessionID     = "lifi-escrow"
	LighterSessionID        = "lighter"
	LifiUnlockSessionID     = "lifi-unlock"
)
View Source
const HealthTimeout = 10 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type Communication

type Communication interface {
	// CloseSession closes and removes all streams for that session
	CloseSession(sessionID string)
	// Broadcast sends message to provided peers
	// If error has occurred on sending any message, broadcast will be aborted and error will be sent to errChan
	Broadcast(peers peer.IDSlice, msg []byte, msgType MessageType, sessionID string) error
	// Subscribe subscribes provided channel to a specific message type for a provided session
	// Returns SubscriptionID - unique identifier of created subscription that is used to unsubscribe from subscription
	Subscribe(sessionID string, msgType MessageType, channel chan *WrappedMessage) SubscriptionID
	// UnSubscribe unsubscribes from subscription defined by provided SubscriptionID
	UnSubscribe(subID SubscriptionID)
}

Communication defines methods for communicating between peers

type CommunicationError

type CommunicationError struct {
	Peer peer.ID
	Err  error
}

func ExecuteCommHealthCheck

func ExecuteCommHealthCheck(communication Communication, peers peer.IDSlice) []*CommunicationError

func (*CommunicationError) Error

func (ce *CommunicationError) Error() string

type MessageType

type MessageType int64

MessageType represents message type identificator

const (
	// TssKeyGenMsg message type used for communicating key generation.
	TssKeyGenMsg MessageType = iota
	// TssKeySignMsg message type used for communicating signature for specific message.
	TssKeySignMsg
	// TssInitiateMsg message type sent by the leader to signify preparation for a tss process.
	TssInitiateMsg
	// TssStartMsg message type sent by a leader to signify the start of a tss process after parties sent the ready message.
	TssStartMsg
	// TssFailMsg message type sent by parties after an communication or tss error happens during process.
	TssFailMsg
	// TssReadyMsg message type sent by coordinator sent if the process fails.
	TssReadyMsg
	// TssReshareMsg message type used for resharing tss messages.
	TssReshareMsg
	// CoordinatorElectionMsg message type used to communicate that new election process needs to start.
	CoordinatorElectionMsg
	// CoordinatorAliveMsg  message type used to respond on CoordinatorElectionMsg message, signaling that peer is alive and ready for new election process.
	CoordinatorAliveMsg
	// CoordinatorLeaveMsg message type used to communicate that peer is going offline and will not participate in the future.
	CoordinatorLeaveMsg
	// CoordinatorSelectMsg message type used to communicate that sender has pronounced itself as a leader.
	CoordinatorSelectMsg
	// CoordinatorPingMsg message type used to check if the current coordinator is alive.
	CoordinatorPingMsg
	// CoordinatorPingResponseMsg message type used to respond on CoordinatorPingMsg message.
	CoordinatorPingResponseMsg
	// SignatureMsg message type is used to the share the signature to all relayers
	SignatureMsg
	// AcrossMsg message type is used for the process coordinator to share across data
	AcrossMsg
	// SprinterCreditMsg message type is used for the process coordinator to share sprinter data
	SprinterCreditMsg
	// LighterMsg message type is used for the process coordinator to share lighter data
	LighterMsg
	// LifiEscrowMsg message type is used for the process coordinator to share lifi data
	LifiEscrowMsg
	// LifiUnlockMsg message type is used for the process coordinator to share lifi unlock data
	LifiUnlockMsg
	// Unknown message type
	Unknown
)

func (MessageType) String

func (msgType MessageType) String() string

String implements fmt.Stringer

type SubscriptionID

type SubscriptionID string

SubscriptionID is unique identifier for each subscription It is defined as: SessionID-MessageType-SubscriptionIdentifier

func NewSubscriptionID

func NewSubscriptionID(sessionID string, msgType MessageType) SubscriptionID

func (SubscriptionID) MessageType

func (sID SubscriptionID) MessageType() MessageType

func (SubscriptionID) SessionID

func (sID SubscriptionID) SessionID() string

func (SubscriptionID) SubscriptionIdentifier

func (sID SubscriptionID) SubscriptionIdentifier() string

func (SubscriptionID) Unwrap

func (sID SubscriptionID) Unwrap() (string, MessageType, string, error)

type WrappedMessage

type WrappedMessage struct {
	MessageType MessageType `json:"message_type"`
	SessionID   string      `json:"message_id"`
	Payload     []byte      `json:"payload"`
	From        peer.ID     `json:"-"`
}

WrappedMessage is a structure representing a raw message that is sent trough Communication

Directories

Path Synopsis
Package mock_comm is a generated GoMock package.
Package mock_comm is a generated GoMock package.
p2p
mock/conn
Package mock_network is a generated GoMock package.
Package mock_network is a generated GoMock package.
mock/host
Package mock_host is a generated GoMock package.
Package mock_host is a generated GoMock package.
mock/stream
Package mock_network is a generated GoMock package.
Package mock_network is a generated GoMock package.

Jump to

Keyboard shortcuts

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