Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add utility to update socket #188

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Transactor interface {
// are also returned.
GetOperatorStakes(ctx context.Context, operatorID OperatorID, blockNumber uint32) (OperatorStakes, []QuorumID, error)

// GetOperatorStakes returns the stakes of all operators within the supplied quorums. The returned stakes are for the block number supplied.
// GetOperatorStakesForQuorums returns the stakes of all operators within the supplied quorums. The returned stakes are for the block number supplied.
// The indices of the operators within each quorum are also returned.
GetOperatorStakesForQuorums(ctx context.Context, quorums []QuorumID, blockNumber uint32) (OperatorStakes, error)

Expand Down
7 changes: 6 additions & 1 deletion node/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Operator struct {
QuorumIDs []core.QuorumID
}

// Register operator registers the operator with the given public key for the given quorum IDs.
// RegisterOperator operator registers the operator with the given public key for the given quorum IDs.
func RegisterOperator(ctx context.Context, operator *Operator, transactor core.Transactor, churnerUrl string, useSecureGrpc bool, logger common.Logger) error {
registeredQuorumIds, err := transactor.GetRegisteredQuorumIdsForOperator(ctx, operator.OperatorId)
if err != nil {
Expand Down Expand Up @@ -111,6 +111,11 @@ func UpdateOperatorQuorums(
return RegisterOperator(ctx, operator, transactor, churnerUrl, useSecureGrpc, logger)
}

// UpdateOperatorSocket updates the socket for the given operator
func UpdateOperatorSocket(ctx context.Context, transactor core.Transactor, socket string) error {
return transactor.UpdateOperatorSocket(ctx, socket)
}

func requestChurnApproval(ctx context.Context, operator *Operator, churnerUrl string, useSecureGrpc bool, logger common.Logger) (*grpcchurner.ChurnReply, error) {
logger.Info("churner url", "url", churnerUrl)

Expand Down
8 changes: 8 additions & 0 deletions node/plugin/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ func pluginOps(ctx *cli.Context) {
return
}
log.Printf("Info: successfully updated quorums, for operator ID: %x, operator address: %x, socket: %s, and quorums: %v", operatorID, sk.Address, config.Socket, config.QuorumIDList)
} else if config.Operation == "update-socket" {
shrimalmadhur marked this conversation as resolved.
Show resolved Hide resolved
log.Printf("Info: Operator with Operator Address: %x is updating its socket: %s", sk.Address, config.Socket)
err = node.UpdateOperatorSocket(context.Background(), tx, config.Socket)
if err != nil {
log.Printf("Error: failed to update socket for operator ID: %x, operator address: %x, socket: %s, error: %v", operatorID, sk.Address, config.Socket, err)
return
}
log.Printf("Info: successfully updated socket, for operator ID: %x, operator address: %x, socket: %s", operatorID, sk.Address, config.Socket)
} else {
log.Fatalf("Fatal: unsupported operation: %s", config.Operation)
}
Expand Down
Loading