-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
49 lines (38 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"context"
"fmt"
"time"
"log"
substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
"github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer"
)
func powerOn() error {
mnemonics := "<mnemonics goes here>"
subManager := substrate.NewManager("wss://tfchain.dev.grid.tf/ws")
client, err := peer.NewRpcClient(
context.Background(),
mnemonics,
subManager,
peer.WithRelay("wss://relay.dev.grid.tf"),
peer.WithSession("test-include"),
)
if err != nil {
return fmt.Errorf("failed to create rpc client: %w", err)
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
farmID := 53 // <- replace this with the farm id of the farmerbot
service := fmt.Sprintf("farmerbot-%d", farmID)
const farmerbotTwinID = 164 // <- replace this with the twin id of where the farmerbot is running
nodeID := uint32(83)
if err := client.CallWithSession(ctx, farmerbotTwinID, &service, "farmerbot.powermanager.includenode", nodeID, nil); err != nil {
return err
}
return nil
}
func main() {
if err := powerOn(); err != nil {
log.Fatal(err)
}
}