Commit ce0be510 authored by duanjinfei's avatar duanjinfei

add batch send tx count

parent a5410c05
......@@ -10,7 +10,7 @@ import (
var (
initAcc, initCmp, batchSign, batchRecover, batchRecoverTx, batchVerify bool
txCount, goRoutineCount, cmpAmount int
txCount, goRoutineCount, cmpAmount, batchCount int
cpuProfile string
cfg *tool.Config
)
......@@ -25,7 +25,8 @@ func init() {
startCmd.PersistentFlags().BoolVar(&batchRecoverTx, "batchRecoverTx", false, "test grpc interface -> batchRecoverTx")
startCmd.PersistentFlags().BoolVar(&batchVerify, "batchVerify", false, "test grpc interface -> batchVerify")
startCmd.PersistentFlags().IntVar(&txCount, "txCount", 1000, "send tran count")
startCmd.PersistentFlags().IntVar(&goRoutineCount, "goRoutineCount", 100, "send tran engagement count")
startCmd.PersistentFlags().IntVar(&goRoutineCount, "goRoutineCount", 100, "send tran goRoutine count")
startCmd.PersistentFlags().IntVar(&batchCount, "batchCount", 100, "batch send tran count")
startCmd.AddCommand(initCmd)
}
......
......@@ -20,6 +20,7 @@ func init() {
cfg.StorageAccFileName += ".xlsx"
cfg.GoRoutineCount = goRoutineCount
cfg.SignCount = txCount / 100
cfg.BatchCount = batchCount
SendTxAccountArr = tool.ReadExcel(cfg.Count, cfg.StorageAccFileName)
}
......
......@@ -11,6 +11,7 @@ type Config struct {
ReceiveAddr string `json:"receiveAddr"`
Count int `json:"count"`
SignCount int `json:"signCount"`
BatchCount int `json:"batchCount"`
GoRoutineCount int `json:"goRoutineCount"`
Type int `json:"type"`
RpcNode string `json:"rpcNode"`
......
......@@ -252,6 +252,27 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
rawTxArr := make([]*v1.MetaTxBase, 0)
for i := 0; i < int(allSignedTxCount); i++ {
tran := tranArr[i]
rawTx := constructionRawTx(tran)
rawTxArr = append(rawTxArr, &rawTx)
if len(rawTxArr) == cfg.BatchCount {
req := crypterv1.BatchRecoverTxRequest{
RawTx: rawTxArr,
}
batchRecoverTxRequest <- &req
rawTxArr = make([]*v1.MetaTxBase, 0)
}
}
for {
if bathHandleSendCount == allSignedTxCount/int64(cfg.BatchCount) {
log.Infof("Send tran count: %d", bathHandleSendCount)
log.Infof("Since time: %d ms", time.Since(startTime).Milliseconds())
break
}
}
return nil
}
func constructionRawTx(tran *types.Transaction) v1.MetaTxBase {
v, r, s := tran.RawSignatureValues()
toAddr := metatypes.BytesToAddress(tran.To().Bytes())
hash := metatypes.HexToHash(tran.Hash().Hex())
......@@ -276,21 +297,5 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
S: ns,
TxHash: &hash,
}
rawTxArr = append(rawTxArr, &rawTx)
req := crypterv1.BatchRecoverTxRequest{
RawTx: rawTxArr,
}
if len(rawTxArr) == cfg.SignCount {
batchRecoverTxRequest <- &req
rawTxArr = make([]*v1.MetaTxBase, 0)
}
}
for {
if bathHandleSendCount == allSignedTxCount/int64(cfg.SignCount) {
log.Infof("Send tran count: %d", bathHandleSendCount)
log.Infof("Since time: %d ms", time.Since(startTime).Milliseconds())
break
}
}
return nil
return rawTx
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment