Commit da30d89a authored by duanjinfei's avatar duanjinfei

broadcast tx init goroutine

parent f226e6c0
...@@ -37,6 +37,9 @@ func startTest() { ...@@ -37,6 +37,9 @@ func startTest() {
return return
} }
go func() { go func() {
if err := transaction.InitBroadcastTxGoroutine(cfg); err != nil {
log.Errorf("Init broadcast tx goroutine error: %s", err)
}
for { for {
select { select {
case arr := <-tranArrChan: case arr := <-tranArrChan:
......
...@@ -24,7 +24,7 @@ func init() { ...@@ -24,7 +24,7 @@ func init() {
broadcastEthTxWithFromRequestsArr = make(chan *ring.BroadcastEthTxWithFromRequests, 1000000) broadcastEthTxWithFromRequestsArr = make(chan *ring.BroadcastEthTxWithFromRequests, 1000000)
} }
func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error { func InitBroadcastTxGoroutine(cfg *tool.Config) error {
client, err := grpc.Dial(cfg.RpcNode, grpc.WithTransportCredentials(insecure.NewCredentials())) client, err := grpc.Dial(cfg.RpcNode, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil { if err != nil {
return err return err
...@@ -33,9 +33,13 @@ func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error { ...@@ -33,9 +33,13 @@ func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error {
for i := 0; i < cfg.GoRoutineCount; i++ { for i := 0; i < cfg.GoRoutineCount; i++ {
go broadcastTx(cfg, ringServiceClient) go broadcastTx(cfg, ringServiceClient)
} }
return nil
}
func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error {
allSignedTxCount = int64(len(tranArr)) allSignedTxCount = int64(len(tranArr))
log.Info("allSignedTxCount:", allSignedTxCount) log.Info("allSignedTxCount:", allSignedTxCount)
startTime := time.Now() //startTime := time.Now()
ethTxArr := make([]*ring.BroadcastEthTxWithFromRequest, 0) ethTxArr := make([]*ring.BroadcastEthTxWithFromRequest, 0)
for i := 0; i < int(allSignedTxCount); i++ { for i := 0; i < int(allSignedTxCount); i++ {
inner := constructionEthLegacyTx(tranArr[i].Tran) inner := constructionEthLegacyTx(tranArr[i].Tran)
...@@ -57,16 +61,16 @@ func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error { ...@@ -57,16 +61,16 @@ func BroadcastTxArr(tranArr []*TxFromTran, cfg *tool.Config) error {
ethTxArr = make([]*ring.BroadcastEthTxWithFromRequest, 0) ethTxArr = make([]*ring.BroadcastEthTxWithFromRequest, 0)
} }
} }
for { //for {
if bathHandleSendCount == allSignedTxCount { // if bathHandleSendCount == allSignedTxCount {
log.Info("beforeBathHandleSendCount:", beforeBathHandleSendCount) // log.Info("beforeBathHandleSendCount:", beforeBathHandleSendCount)
log.Infof("Send tran count: %d", bathHandleSendCount) // log.Infof("Send tran count: %d", bathHandleSendCount)
log.Infof("Since time: %d ms", time.Since(startTime).Milliseconds()) // log.Infof("Since time: %d ms", time.Since(startTime).Milliseconds())
log.Infof("Send tran total time: %d ms", totalSendTime) // log.Infof("Send tran total time: %d ms", totalSendTime)
bathHandleSendCount = 0 // bathHandleSendCount = 0
break // break
} // }
} //}
return nil return nil
} }
......
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