Commit 246d11b1 authored by duanjinfei's avatar duanjinfei

change continued send tx

parent 686ef581
...@@ -4,10 +4,13 @@ import ( ...@@ -4,10 +4,13 @@ import (
"ChainGrpcTest/log" "ChainGrpcTest/log"
"ChainGrpcTest/tool" "ChainGrpcTest/tool"
"ChainGrpcTest/transaction" "ChainGrpcTest/transaction"
"github.com/ethereum/go-ethereum/core/types"
"sync"
) )
var ( var (
SendTxAccountArr [][]string SendTxAccountArr [][]string
tranArrChan chan []*types.Transaction
) )
func init() { func init() {
...@@ -18,9 +21,11 @@ func init() { ...@@ -18,9 +21,11 @@ func init() {
return return
} }
cfg.StorageAccFileName += ".xlsx" cfg.StorageAccFileName += ".xlsx"
tranArrChan = make(chan []*types.Transaction, 1000000000)
} }
func startTest() { func startTest() {
if broadcastTxArr {
SendTxAccountArr = tool.ReadExcelOfStartEnd(startCount, endCount, cfg.StorageAccFileName) SendTxAccountArr = tool.ReadExcelOfStartEnd(startCount, endCount, cfg.StorageAccFileName)
log.Infof("Program start initAccCount:%d tranCount", cfg.Count) log.Infof("Program start initAccCount:%d tranCount", cfg.Count)
cfg.GoRoutineCount = goRoutineCount cfg.GoRoutineCount = goRoutineCount
...@@ -31,12 +36,36 @@ func startTest() { ...@@ -31,12 +36,36 @@ func startTest() {
log.Errorf("Bath Send Tran error: %s", err) log.Errorf("Bath Send Tran error: %s", err)
return return
} }
arr := transaction.SignedTxArr(syncMap, SendTxAccountArr, cfg) go func() {
if broadcastTxArr { for {
select {
case arr := <-tranArrChan:
if err := transaction.BroadcastTxArr(arr, cfg); err != nil { if err := transaction.BroadcastTxArr(arr, cfg); err != nil {
log.Errorf("Bath Send Tran error: %s", err) log.Errorf("Bath Send Tran error: %s", err)
return return
} }
} }
}
}()
for {
arr := transaction.SignedTxArr(syncMap, SendTxAccountArr, cfg)
tranArrChan <- arr
updateNonce(syncMap, cfg)
}
}
}
func updateNonce(nonceMap sync.Map, cfg *tool.Config) {
nonceMap.Range(func(key, value any) bool {
load, ok := nonceMap.Load(key)
if !ok {
return false
}
nonceMap.Store(key, load.(int)+cfg.SignCount)
load, ok = nonceMap.Load(key)
if !ok {
return false
}
log.Info("updated addr nonce:", load)
return true
})
} }
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