Skip to content

Commit

Permalink
add utility to update socket (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur authored Jan 18, 2024
1 parent 5d1e8e6 commit 9d4be86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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" {
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

0 comments on commit 9d4be86

Please sign in to comment.