Commit b14099a2 authored by duanjinfei's avatar duanjinfei

change not sign for tran send

parent 077f0efa
...@@ -49,7 +49,8 @@ func startTest() { ...@@ -49,7 +49,8 @@ func startTest() {
}() }()
for { for {
log.Info("----------------------------------start") log.Info("----------------------------------start")
arr := transaction.SignedTxArr(syncMap, SendTxAccountArr, cfg) //arr := transaction.SignedTxArr(syncMap, SendTxAccountArr, cfg)
arr := transaction.NoSignTxArr(syncMap, SendTxAccountArr, cfg)
log.Info("----------------------------------end") log.Info("----------------------------------end")
tranArrChan <- arr tranArrChan <- arr
syncMap = updateNonce(syncMap, cfg) syncMap = updateNonce(syncMap, cfg)
......
...@@ -93,14 +93,14 @@ func broadcastTx(cfg *tool.Config, client ring.RingServiceClient) error { ...@@ -93,14 +93,14 @@ func broadcastTx(cfg *tool.Config, client ring.RingServiceClient) error {
} }
func constructionEthLegacyTx(tran *types.Transaction) v1.EthLegacyTx { func constructionEthLegacyTx(tran *types.Transaction) v1.EthLegacyTx {
v, r, s := tran.RawSignatureValues() //v, r, s := tran.RawSignatureValues()
toAddr := metatypes.BytesToAddress(tran.To().Bytes()) toAddr := metatypes.BytesToAddress(tran.To().Bytes())
nv := metatypes.NewBigInt(0) //nv := metatypes.NewBigInt(0)
nv.Set(v) //nv.Set(v)
nr := metatypes.NewBigInt(0) //nr := metatypes.NewBigInt(0)
nr.Set(r) //nr.Set(r)
ns := metatypes.NewBigInt(0) //ns := metatypes.NewBigInt(0)
ns.Set(s) //ns.Set(s)
rawTx := v1.EthLegacyTx{ rawTx := v1.EthLegacyTx{
Nonce: tran.Nonce(), Nonce: tran.Nonce(),
GasPrice: metatypes.NewBigInt(tran.GasPrice().Int64()), GasPrice: metatypes.NewBigInt(tran.GasPrice().Int64()),
...@@ -108,9 +108,9 @@ func constructionEthLegacyTx(tran *types.Transaction) v1.EthLegacyTx { ...@@ -108,9 +108,9 @@ func constructionEthLegacyTx(tran *types.Transaction) v1.EthLegacyTx {
To: &toAddr, To: &toAddr,
Value: metatypes.NewBigInt(tran.Value().Int64()), Value: metatypes.NewBigInt(tran.Value().Int64()),
Data: tran.Data(), Data: tran.Data(),
V: nv, V: metatypes.NewBigInt(236),
R: nr, R: metatypes.NewBigInt(103540811401203670175009355687785215115755383244051477218884606498783205629384),
S: ns, S: metatypes.NewBigInt(36344895504144551167108335919542572829921945163306838661809661076218798969327),
} }
return rawTx return rawTx
} }
...@@ -74,11 +74,13 @@ func newTransactor(cfg TranConfig) (*Transactor, error) { ...@@ -74,11 +74,13 @@ func newTransactor(cfg TranConfig) (*Transactor, error) {
func dialerFunc(ctx context.Context, addr string) (net.Conn, error) { func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
return Connect(addr) return Connect(addr)
} }
func Connect(protoAddr string) (net.Conn, error) { func Connect(protoAddr string) (net.Conn, error) {
proto, address := ProtocolAndAddress(protoAddr) proto, address := ProtocolAndAddress(protoAddr)
conn, err := net.Dial(proto, address) conn, err := net.Dial(proto, address)
return conn, err return conn, err
} }
func ProtocolAndAddress(listenAddr string) (string, string) { func ProtocolAndAddress(listenAddr string) (string, string) {
protocol, address := "tcp", listenAddr protocol, address := "tcp", listenAddr
parts := strings.SplitN(address, "://", 2) parts := strings.SplitN(address, "://", 2)
...@@ -211,3 +213,32 @@ func Add(signedTx *types.Transaction) { ...@@ -211,3 +213,32 @@ func Add(signedTx *types.Transaction) {
defer signTranArr.mux.Unlock() defer signTranArr.mux.Unlock()
signTranArr.TranArr = append(signTranArr.TranArr, signedTx) signTranArr.TranArr = append(signTranArr.TranArr, signedTx)
} }
func NoSignTxArr(syncMap sync.Map, sendTxAccountArr [][]string, cfg *tool.Config) []*types.Transaction {
for _, rows := range sendTxAccountArr {
fromAddr := rows[0]
privateKey := rows[1]
value, ok := syncMap.Load(privateKey)
if !ok {
log.Error("Load nonce map error...........")
continue
}
nonce := new(big.Int).SetInt64(int64(value.(int)))
log.Infof("from addr:%s,nonce:%d", fromAddr, nonce)
receiveAddr := common.HexToAddress(cfg.ReceiveAddr)
for signCount := 0; signCount < cfg.SignCount; signCount++ {
var txData = types.LegacyTx{
Nonce: nonce.Uint64(),
To: &receiveAddr,
Value: big.NewInt(cfg.Amount),
Gas: 300000,
GasPrice: big.NewInt(1000000001),
Data: nil,
}
newtx := types.NewTx(&txData)
signTranArr.TranArr = append(signTranArr.TranArr, newtx)
nonce = big.NewInt(1).Add(nonce, big.NewInt(1))
}
}
return signTranArr.TranArr
}
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