diff --git a/cmd/sendtx/batch.py b/cmd/sendtx/batch.py index 5483e5b8..dcf38348 100644 --- a/cmd/sendtx/batch.py +++ b/cmd/sendtx/batch.py @@ -10,7 +10,7 @@ import random ADMIN='c921c91aa4c5f9886bd1e084a848e7e564644d5cc2f265beebb0d51bd251b7e7' ACCS=100 -TX_NUM=120 +TX_NUM=100 PERIOD=600 NODES=['http://127.0.0.1:8811', 'http://127.0.0.1:8822', 'http://127.0.0.1:8833', 'http://127.0.0.1:8844'] diff --git a/cmd/sendtx/cmd.go b/cmd/sendtx/cmd.go index 70f98e0e..d26be28c 100644 --- a/cmd/sendtx/cmd.go +++ b/cmd/sendtx/cmd.go @@ -138,15 +138,6 @@ func sendTx(conn *ethclient.Client, tx *types.Transaction) error { return nil } -func sendTxs(conn *ethclient.Client, txs []*types.Transaction) error { - err := conn.SendTransactions(context.Background(), txs) - if err != nil { - return err - } - fmt.Println("txs", len(txs)) - return nil -} - func sendEther(prv *ecdsa.PrivateKey, to common.Address, amount *big.Int, nonce uint64) (*types.Transaction, error) { signer := types.FrontierSigner{} tx := types.NewTransaction(nonce, to, amount, big.NewInt(GAS_LIMIT), big.NewInt(GAS_PRICE), []byte{}) @@ -209,20 +200,19 @@ func batchSend(conn *ethclient.Client, prv *ecdsa.PrivateKey, to common.Address, return default: fmt.Println("round", round) - var txs []*types.Transaction for i := 0; i < count; i++ { tx, err := sendEther(prv, to, common.Big1, nonce) if err != nil { fmt.Printf("Failed to gen tx, err:%v\n", err) continue } - txs = append(txs, tx) + err = sendTx(conn, tx) + if err != nil { + fmt.Printf("Failed to send tx, err:%v\n", err) + continue + } nonce++ } - err := sendTxs(conn, txs) - if err != nil { - fmt.Printf("Failed to send txs, err:%v\n", err) - } round++ <-time.After(time.Duration(20+rand.Int()%10) * time.Second) }