coordinator

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateThreshold

func CalculateThreshold(numParticipants int) int

CalculateThreshold calculates the threshold as > 2/3 of participants. Formula: threshold = floor((2 * n) / 3) + 1 This ensures threshold > 2/3 * n

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator handles coordinator logic for TSS events.

func NewCoordinator

func NewCoordinator(
	eventStore *eventstore.Store,
	pushCore *pushcore.Client,
	keyshareManager *keyshare.Manager,
	validatorAddress string,
	coordinatorRange uint64,
	pollInterval time.Duration,
	send SendFunc,
	logger zerolog.Logger,
) *Coordinator

NewCoordinator creates a new coordinator.

func (*Coordinator) GetCurrentTSSKeyId

func (c *Coordinator) GetCurrentTSSKeyId() (string, error)

GetCurrentTSSKeyId gets the current TSS key ID from pushCore.

func (*Coordinator) GetEligibleUV

func (c *Coordinator) GetEligibleUV(protocolType string) []*types.UniversalValidator

GetEligibleUV returns eligible validators for the given protocol type. Uses cached allValidators for performance. For sign: returns ALL eligible validators (Active + Pending Leave), not a random subset. This is used for validation - the random subset selection happens only in processEventAsCoordinator.

func (*Coordinator) GetLatestBlockNum

func (c *Coordinator) GetLatestBlockNum() (uint64, error)

GetLatestBlockNum gets the latest block number from pushCore.

func (*Coordinator) GetMultiAddrsFromPeerID

func (c *Coordinator) GetMultiAddrsFromPeerID(ctx context.Context, peerID string) ([]string, error)

GetMultiAddrsFromPeerID gets the multiaddrs for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPartyIDFromPeerID

func (c *Coordinator) GetPartyIDFromPeerID(ctx context.Context, peerID string) (string, error)

GetPartyIDFromPeerID gets the partyID (validator address) for a given peerID. Uses cached allValidators for performance.

func (*Coordinator) GetPeerIDFromPartyID

func (c *Coordinator) GetPeerIDFromPartyID(ctx context.Context, partyID string) (string, error)

GetPeerIDFromPartyID gets the peerID for a given partyID (validator address). Uses cached allValidators for performance.

func (*Coordinator) HandleACK

func (c *Coordinator) HandleACK(ctx context.Context, senderPeerID string, eventID string) error

HandleACK processes an ACK message from a participant. This is called by the session manager when coordinator receives an ACK.

func (*Coordinator) IsPeerCoordinator

func (c *Coordinator) IsPeerCoordinator(ctx context.Context, peerID string) (bool, error)

IsPeerCoordinator checks if the given peerID is the coordinator for the current block. Uses cached allValidators for performance.

func (*Coordinator) Start

func (c *Coordinator) Start(ctx context.Context)

Start starts the coordinator loop.

func (*Coordinator) Stop

func (c *Coordinator) Stop()

Stop stops the coordinator loop.

type Message

type Message struct {
	Type         string   `json:"type"` // "setup", "ack", "begin", "step"
	EventID      string   `json:"eventId"`
	Payload      []byte   `json:"payload"`
	Participants []string `json:"participants"` // Array of PartyIDs (validator addresses) participating in this process
}

Message represents a simple message with type, eventId, payload, and participants.

type ProtocolType

type ProtocolType string

ProtocolType enumerates the supported DKLS protocol flows.

const (
	ProtocolKeygen       ProtocolType = "keygen"
	ProtocolKeyrefresh   ProtocolType = "keyrefresh"
	ProtocolQuorumChange ProtocolType = "quorumchange"
	ProtocolSign         ProtocolType = "sign"
)

type SendFunc

type SendFunc func(ctx context.Context, peerID string, data []byte) error

SendFunc is a function type for sending messages to participants. peerID: The peer ID of the recipient data: The message bytes

Jump to

Keyboard shortcuts

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