|
1 | 1 | package cli
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "fmt" |
| 5 | + "log" |
4 | 6 | "os"
|
| 7 | + "os/exec" |
5 | 8 | "time"
|
6 | 9 |
|
7 | 10 | "github.com/manifoldco/promptui"
|
8 | 11 | "github.com/spf13/cobra"
|
| 12 | + "golang.org/x/exp/slices" |
9 | 13 | "google.golang.org/protobuf/types/known/anypb"
|
10 | 14 |
|
11 | 15 | "github.com/pokt-network/pocket/app/client/cli/helpers"
|
@@ -109,6 +113,29 @@ func newDebugSubCommands() []*cobra.Command {
|
109 | 113 | })
|
110 | 114 | },
|
111 | 115 | },
|
| 116 | + { |
| 117 | + Use: "ScaleActor", |
| 118 | + Aliases: []string{"scale"}, |
| 119 | + Short: "Scales the number of actors up or down", |
| 120 | + Long: "Scales the type of actor specified to the number provided", |
| 121 | + Args: cobra.ExactArgs(2), |
| 122 | + PersistentPreRunE: helpers.P2PDependenciesPreRunE, |
| 123 | + Run: func(cmd *cobra.Command, args []string) { |
| 124 | + fmt.Println("OLSH ARGS", args) |
| 125 | + actor := args[0] |
| 126 | + numActors := args[1] |
| 127 | + validActors := []string{"fishermen", "full_nodes", "servicers", "validators"} |
| 128 | + if !slices.Contains(validActors, actor) { |
| 129 | + logger.Global.Fatal().Msg("Invalid actor type provided") |
| 130 | + } |
| 131 | + sedCmd := exec.Command("sed", "-i", fmt.Sprintf("/%s:/,/count:/ s/count: [0-9]*/count: %s/", actor, numActors), "/usr/local/localnet_config.yaml") |
| 132 | + // fmt.Println(sedCmd.String()) |
| 133 | + err := sedCmd.Run() |
| 134 | + if err != nil { |
| 135 | + log.Fatal(err) |
| 136 | + } |
| 137 | + }, |
| 138 | + }, |
112 | 139 | }
|
113 | 140 | return cmds
|
114 | 141 | }
|
@@ -223,9 +250,9 @@ func handleSelect(cmd *cobra.Command, selection string) {
|
223 | 250 | // - Ending the task too early before the debug client completes its task results in a lack of propagation of the message or retrieval of the result
|
224 | 251 | // TECHDEBT: There is likely an event based solution to this but it would require a lot more refactoring of the p2p module.
|
225 | 252 | func runWithSleep(task func()) {
|
226 |
| - time.Sleep(1 * time.Second) |
| 253 | + time.Sleep(1000 * time.Millisecond) |
227 | 254 | task()
|
228 |
| - time.Sleep(1 * time.Second) |
| 255 | + time.Sleep(1000 * time.Millisecond) |
229 | 256 | }
|
230 | 257 |
|
231 | 258 | // broadcastDebugMessage broadcasts the debug message to the entire visible network.
|
|
0 commit comments