Commit 9a898188 authored by duanjinfei's avatar duanjinfei

add error addr log print

parent af308d28
......@@ -26,7 +26,7 @@ func init() {
func startTest() {
log.Infof("Program start initAccCount:%d tranCount", cfg.Count)
arr := transaction.SignedTxArr(SendTxAccountArr, cfg)
arr, fromAddrArr := transaction.SignedTxArr(SendTxAccountArr, cfg)
if batchSign {
if err := transaction.BatchSignHandler(arr, cfg); err != nil {
log.Errorf("Bath Send Tran error: %s", err)
......@@ -40,7 +40,7 @@ func startTest() {
}
}
if batchRecoverTx {
if err := transaction.BatchRecoverTxHandler(arr, cfg); err != nil {
if err := transaction.BatchRecoverTxHandler(arr, fromAddrArr, cfg); err != nil {
log.Errorf("Bath Send Tran error: %s", err)
return
}
......
......@@ -7,6 +7,7 @@ import (
v1 "github.com/CaduceusMetaverseProtocol/MetaProtocol/gen/proto/go/base/v1"
crypterv1 "github.com/CaduceusMetaverseProtocol/MetaProtocol/gen/proto/go/crypter/v1"
metatypes "github.com/CaduceusMetaverseProtocol/MetaTypes/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
......@@ -20,13 +21,19 @@ var (
batchRecoverTxRequest chan *crypterv1.BatchRecoverTxRequest
batchVerifyRequest chan *crypterv1.BatchVerifyRequest
bathHandleSendCount, allSignedTxCount, totalSendTime int64
set Set
)
type Set struct {
txArr []*v1.MetaTxBase
}
func init() {
batchSignRequest = make(chan *crypterv1.BatchSignRequest, 1000000)
batchRecoverRequest = make(chan *crypterv1.BatchRecoverRequest, 1000000)
batchRecoverTxRequest = make(chan *crypterv1.BatchRecoverTxRequest, 1000000)
batchVerifyRequest = make(chan *crypterv1.BatchVerifyRequest, 1000000)
set.txArr = make([]*v1.MetaTxBase, 0)
}
// batchSign 发送的签名交易
......@@ -226,7 +233,10 @@ func batchRecoverTx(client crypterv1.CrypterServiceClient, sleepTime int) {
sinceTime := time.Since(sendTranStartTime).Milliseconds()
atomic.AddInt64(&totalSendTime, sinceTime)
for _, tx := range sign.GetRecoverdTx() {
log.Info(" tx_From :", tx.From.Hex())
if set.contain(tx.From) {
continue
}
set.txArr = append(set.txArr, tx)
}
log.Infof("Send transaction time: %d ms", sinceTime)
}
......@@ -234,7 +244,7 @@ func batchRecoverTx(client crypterv1.CrypterServiceClient, sleepTime int) {
}
// BatchRecoverTxHandler 处理批量发送的签名交易
func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error {
func BatchRecoverTxHandler(tranArr []*types.Transaction, fromAddrArr []common.Address, cfg *tool.Config) error {
client, err := grpc.Dial(cfg.RpcNode, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Error("dial nebula failed", "err", err)
......@@ -259,6 +269,12 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
}
for {
if bathHandleSendCount == allSignedTxCount/int64(cfg.BatchCount) {
for _, fromAddr := range fromAddrArr {
address := metatypes.HexToAddress(fromAddr.Hex())
if !set.contain(&address) {
log.Error("not contain from addr:", address)
}
}
log.Infof("Send tran count: %d", bathHandleSendCount)
log.Infof("Since time: %d ms", time.Since(startTime).Milliseconds())
break
......@@ -294,3 +310,12 @@ func constructionRawTx(tran *types.Transaction) v1.MetaTxBase {
}
return rawTx
}
func (s *Set) contain(metaBase *metatypes.Address) bool {
for _, tx := range s.txArr {
if tx.From == metaBase {
return true
}
}
return false
}
......@@ -49,10 +49,12 @@ func newTransactor(cfg TranConfig) (*Transactor, error) {
}
// SignedTxArr 获取全部签名数据
func SignedTxArr(sendTxAccountArr [][]string, cfg *tool.Config) []*types.Transaction {
func SignedTxArr(sendTxAccountArr [][]string, cfg *tool.Config) ([]*types.Transaction, []common.Address) {
tranArr := make([]*types.Transaction, 0)
fromAddrArr := make([]common.Address, 0)
var signedTx *types.Transaction
for _, rows := range sendTxAccountArr {
fromAddrArr = append(fromAddrArr, common.HexToAddress(rows[0]))
privateKey := rows[1]
nonce := big.NewInt(1)
for signCount := 0; signCount < cfg.SignCount; signCount++ {
......@@ -74,7 +76,7 @@ func SignedTxArr(sendTxAccountArr [][]string, cfg *tool.Config) []*types.Transac
tranArr = append(tranArr, signedTx)
}
}
return tranArr
return tranArr, fromAddrArr
}
// signedTx 签名本币转账交易
......
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