Commit 46fe699c authored by 李伟@五瓣科技's avatar 李伟@五瓣科技

debug consensus tx

parent 0740a8c1
...@@ -6,11 +6,14 @@ import ( ...@@ -6,11 +6,14 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"code.wuban.net.cn/multisend/internal/logging"
) )
var toAddress common.Address = common.HexToAddress("0x0071B39fd266F8aeF392fb50F078A233b2218a0b") var toAddress common.Address = common.HexToAddress("0x0071B39fd266F8aeF392fb50F078A233b2218a0b")
...@@ -31,6 +34,7 @@ type EthClient struct { ...@@ -31,6 +34,7 @@ type EthClient struct {
GasPrice *big.Int GasPrice *big.Int
ChainId *big.Int ChainId *big.Int
GasLimit uint64 GasLimit uint64
logger logging.Logger
} }
var _ ClientFactory = (*EthClientFactory)(nil) var _ ClientFactory = (*EthClientFactory)(nil)
...@@ -61,6 +65,7 @@ func (f *EthClientFactory) NewClient(cfg Config) (Client, error) { ...@@ -61,6 +65,7 @@ func (f *EthClientFactory) NewClient(cfg Config) (Client, error) {
PrivateKey: sendTxPrivatekeyAsECDSA, PrivateKey: sendTxPrivatekeyAsECDSA,
FromAddr: sendTxFromAddress, FromAddr: sendTxFromAddress,
NodeUrl: "http://13.40.31.153:8545", NodeUrl: "http://13.40.31.153:8545",
logger: logging.NewLogrusLogger("EthClient"),
} }
cli, err := ethclient.Dial(buildTxParam.NodeUrl) cli, err := ethclient.Dial(buildTxParam.NodeUrl)
...@@ -117,6 +122,15 @@ func (c *EthClient) GenerateTx() (*types.Transaction, error) { ...@@ -117,6 +122,15 @@ func (c *EthClient) GenerateTx() (*types.Transaction, error) {
return nil, err return nil, err
} }
data, err := tx.MarshalBinary()
if err != nil {
return nil, err
}
args := hexutil.Encode(data)
c.logger.Info("build tx", "nonce", c.Nonce, "TxAsHex", args)
c.Nonce += 1 c.Nonce += 1
return tx, nil return tx, nil
......
...@@ -285,7 +285,7 @@ func (t *Transactor) sendTransactions() error { ...@@ -285,7 +285,7 @@ func (t *Transactor) sendTransactions() error {
args := hexutil.Encode(data) args := hexutil.Encode(data)
method := "eth_sendRawTransaction" method := "eth_sendRawTransaction"
t.logger.Info("send tx", "idx", sent, "TxAsHex", args) t.logger.Info("send tx", "idx", sent)
msg, err := t.newMessage(method, args) msg, err := t.newMessage(method, args)
if err != nil { if err != 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