diff --git a/tools/spammer/main.go b/tools/spammer/main.go new file mode 100644 index 0000000000000000000000000000000000000000..cf6adb0b1fb345e7ae9fc401070efbb09b214bf3 --- /dev/null +++ b/tools/spammer/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + + "github.com/iotaledger/goshimmer/client" + flag "github.com/spf13/pflag" + "github.com/spf13/viper" +) + +const ( + cfgNodeURI = "node" + cfgMessage = "message" +) + +func init() { + flag.String(cfgNodeURI, "http://127.0.0.1:8080", "the URI of the node API") + flag.String(cfgMessage, "", "the URI of the node API") +} + +func main() { + flag.Parse() + if err := viper.BindPFlags(flag.CommandLine); err != nil { + panic(err) + } + goshimAPI := client.NewGoShimmerAPI(viper.GetString(cfgNodeURI)) + messageBytes := []byte(viper.GetString(cfgMessage)) + var issued, failed int + for { + fmt.Printf("issued %d, failed %d\r", issued, failed) + _, err := goshimAPI.Data(messageBytes) + if err != nil { + failed++ + continue + } + issued++ + } +}