discovery

package
v0.0.0-...-7cd50c7 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	PeerBasePort    = 10000
	WildcardAllTags = "__all__" // Used by the master only, and thus not part of the slave wildcard replacement.

	// These wildcards will be replaced in command arguments
	// and output file name by the corresponding values
	// when the slave executes the exec-start master command
	// (not to be confused by the command to execute).
	WildcardSlaveID   = "__id__"
	WildcardPublicIP  = "__public_ip__"
	WildcardPrivateIP = "__private_ip__"
)

Variables

This section is empty.

Functions

func ParseCommandStr

func ParseCommandStr(cmdStr string, tokenChannel chan string)

func RegisterClient

func RegisterClient(serverAddrPort string) (int32, []*pb.NodeIdentity)

func RegisterPeer

func RegisterPeer(serverAddrPort string, ownPublicIP string, ownPrivateIP string) (int32, []*pb.NodeIdentity, []byte, []byte, []byte, []byte, [][]byte, [][][]byte, [][]byte)

func RunDiscoveryServer

func RunDiscoveryServer(port string, grpcServer *grpc.Server, discoveryImpl *DiscoveryServer, wg *sync.WaitGroup)

Runs the discovery server. Meant to be run as a separate goroutine. Calls Done() on the wg argument when finished. (Used for synchronization)

func SyncPeer

func SyncPeer(serverAddrPort string, ownPeerID int32)

Types

type DiscoveryServer

type DiscoveryServer struct {
	TBLSPublicKey        []byte          // Public key of the BLS threshold cryptosystem
	TBLSPrivateKeyShares [][]byte        // Privte key shares of the BLS threshold cryptosystem
	BLSPublicKey         []byte          // Public key of the BLS threshold cryptosystem
	BLSPrivateKeyShares  [][][]byte      // Privte key shares of the BLS threshold cryptosystem
	BLSPublicKeyShares   []*pb.PubKeyMsg // Public key shares of the BLS threshold cryptosystem
	BLSIds               [][][]byte      // Ids of the BLS threshold cryptosystem

	BLSkeyGenOnce sync.Once // Used to generate the keys for the BLS threshold cryptosystem once, to be included in the response sent to all peers.
	// contains filtered or unexported fields
}

Represents a discovery server and saves all its state.

func NewDiscoveryServer

func NewDiscoveryServer() *DiscoveryServer

Creates and initializes a new instance of a discovery server.

func (*DiscoveryServer) DistributeIDs

func (ds *DiscoveryServer) DistributeIDs()

Background goroutine generating IDs on demand.

func (*DiscoveryServer) NextCommand

func (ds *DiscoveryServer) NextCommand(ctx context.Context, status *pb.SlaveStatus) (*pb.MasterCommand, error)

Implements the NextCommand RPC. Updates the status of the command previously executed by the slave, waits until the next command is ready for this slave, and sends this command to the slave. If the request (SlaveStatus) has ID -1, this is the first request of an anonymous slave. In such a case, registers a new slave and responds with initialization command (containing a fresh slave ID).

func (*DiscoveryServer) ProcessCommands

func (ds *DiscoveryServer) ProcessCommands(wg *sync.WaitGroup) chan string

Starts a user command processing goroutine. Returns a channel to which user commands can be written in form of string tokens: command name followed parameters. Processing finishes when the channel is closed. Calls Done() on the provided WaitGroup when tha last command has been processed. ATTENTION: Must not be called a second time before the returned channel is closed and empty!

That might result in undefined behavior, as both instances would be operating on the same slave state.

func (*DiscoveryServer) RegisterClient

Implements the RegisterClient RPC. Used by the client to discover its own ID and the orderer peer identities. Waits until all peers have registered, collects their identities and sends those identities to back to the client.

func (*DiscoveryServer) RegisterPeer

Implements the RegisterPeer RPC. Every node remotely calls this method exactly once at the very start. The discovery server waits until all peers have invoked RegisterPeer, gathers their identities, and only then sends a response (with information about the whole system) to everyone.

func (*DiscoveryServer) StopIDDistribution

func (ds *DiscoveryServer) StopIDDistribution()

func (*DiscoveryServer) SyncPeer

func (ds *DiscoveryServer) SyncPeer(ctx context.Context, req *pb.SyncRequest) (*pb.SyncResponse, error)

Implements the SyncPeer RPC. Synchronizes the current peers. When a peer initializes connections with other peers, it invokes the SyncPeer RPC. Similarly to RegisterPeer, the RPC returns when all peers have invoked SyncPeer, releasing them simultaneously.

Jump to

Keyboard shortcuts

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