tx-spammer/cmd/sendTxs.go

61 lines
1.7 KiB
Go
Raw Normal View History

2020-10-14 15:58:21 +00:00
// Copyright © 2020 Vulcanize, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd
import (
2020-10-14 17:29:14 +00:00
"os"
"os/signal"
"sync"
2020-10-14 15:58:21 +00:00
"github.com/spf13/cobra"
2020-10-14 17:29:14 +00:00
"github.com/vulcanize/tx_spammer/pkg"
2020-10-14 15:58:21 +00:00
)
// sendTxsCmd represents the sendTxs command
var sendTxsCmd = &cobra.Command{
Use: "sendTxs",
2020-10-16 03:10:18 +00:00
Short: "Send large volumes of different tx types to different nodes for testing purposes",
2020-10-14 17:29:14 +00:00
Long: `Loads tx configuration from .toml config file
2020-10-16 03:10:18 +00:00
Generates txs from configuration and sends them to designated node according to set frequency and number
Support standard, optimism L2, optimism L1 to L2, and EIP1559 transactions`,
2020-10-14 15:58:21 +00:00
Run: func(cmd *cobra.Command, args []string) {
2020-10-14 17:29:14 +00:00
sendTxs()
2020-10-14 15:58:21 +00:00
},
}
2020-10-14 17:29:14 +00:00
func sendTxs() {
params, err := tx_spammer.NewTxParams()
if err != nil {
logWithCommand.Fatal(err)
}
txSpammer := tx_spammer.NewTxSpammer(params)
wg := new(sync.WaitGroup)
quitChan := make(chan bool)
txSpammer.Loop(wg, quitChan)
2020-10-16 03:10:18 +00:00
go func() {
shutdown := make(chan os.Signal)
signal.Notify(shutdown, os.Interrupt)
<-shutdown
close(quitChan)
}()
2020-10-14 17:29:14 +00:00
wg.Wait()
}
2020-10-14 15:58:21 +00:00
func init() {
rootCmd.AddCommand(sendTxsCmd)
}