Commit da30d89a authored by duanjinfei's avatar duanjinfei

broadcast tx init goroutine

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