Skip to content

Commit

Permalink
add change power target to go client (#901)
Browse files Browse the repository at this point in the history
* add change power target to go client

* rename function
  • Loading branch information
rawdaGastan authored and sameh-farouk committed Jan 2, 2024
1 parent faaf0c9 commit 5d6a2dd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions clients/tfchain-client-go/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,32 @@ func (s *Substrate) SetNodePowerState(identity Identity, up bool) (hash types.Ha
return callResponse.Hash, nil
}

// SetNodePowerTarget updates the power target of a node
func (s *Substrate) SetNodePowerTarget(identity Identity, nodeID uint32, up bool) (hash types.Hash, err error) {
cl, meta, err := s.GetClient()
if err != nil {
return hash, err
}

power := Power{
IsUp: up,
IsDown: !up,
}

c, err := types.NewCall(meta, "TfgridModule.change_power_target", nodeID, power)

if err != nil {
return hash, errors.Wrap(err, "failed to create call")
}

callResponse, err := s.Call(cl, meta, identity, c)
if err != nil {
return hash, errors.Wrap(err, "failed to change node power target")
}

return callResponse.Hash, nil
}

// GetPowerTarget returns the power target for a node
func (s *Substrate) GetPowerTarget(nodeID uint32) (power NodePower, err error) {
cl, meta, err := s.GetClient()
Expand Down

0 comments on commit 5d6a2dd

Please sign in to comment.