Commit 36f9fd66 authored by 李伟@五瓣科技's avatar 李伟@五瓣科技

update cmd param

parent 9720a44f
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.11.2
// source: batchtx.proto
package multisend
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Tx struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
From []byte `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
To []byte `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
Amount int64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"`
}
func (x *Tx) Reset() {
*x = Tx{}
if protoimpl.UnsafeEnabled {
mi := &file_batchtx_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Tx) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Tx) ProtoMessage() {}
func (x *Tx) ProtoReflect() protoreflect.Message {
mi := &file_batchtx_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Tx.ProtoReflect.Descriptor instead.
func (*Tx) Descriptor() ([]byte, []int) {
return file_batchtx_proto_rawDescGZIP(), []int{0}
}
func (x *Tx) GetFrom() []byte {
if x != nil {
return x.From
}
return nil
}
func (x *Tx) GetTo() []byte {
if x != nil {
return x.To
}
return nil
}
func (x *Tx) GetAmount() int64 {
if x != nil {
return x.Amount
}
return 0
}
type BatchTx struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
Txs []*Tx `protobuf:"bytes,2,rep,name=txs,proto3" json:"txs,omitempty"`
}
func (x *BatchTx) Reset() {
*x = BatchTx{}
if protoimpl.UnsafeEnabled {
mi := &file_batchtx_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BatchTx) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BatchTx) ProtoMessage() {}
func (x *BatchTx) ProtoReflect() protoreflect.Message {
mi := &file_batchtx_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BatchTx.ProtoReflect.Descriptor instead.
func (*BatchTx) Descriptor() ([]byte, []int) {
return file_batchtx_proto_rawDescGZIP(), []int{1}
}
func (x *BatchTx) GetHash() []byte {
if x != nil {
return x.Hash
}
return nil
}
func (x *BatchTx) GetTxs() []*Tx {
if x != nil {
return x.Txs
}
return nil
}
var File_batchtx_proto protoreflect.FileDescriptor
var file_batchtx_proto_rawDesc = []byte{
0x0a, 0x0d, 0x62, 0x61, 0x74, 0x63, 0x68, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x65, 0x6e, 0x64, 0x22, 0x40, 0x0a, 0x02, 0x54, 0x78,
0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x02, 0x74, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3e, 0x0a, 0x07,
0x42, 0x61, 0x74, 0x63, 0x68, 0x54, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1f, 0x0a, 0x03, 0x74,
0x78, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69,
0x73, 0x65, 0x6e, 0x64, 0x2e, 0x54, 0x78, 0x52, 0x03, 0x74, 0x78, 0x73, 0x42, 0x04, 0x5a, 0x02,
0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_batchtx_proto_rawDescOnce sync.Once
file_batchtx_proto_rawDescData = file_batchtx_proto_rawDesc
)
func file_batchtx_proto_rawDescGZIP() []byte {
file_batchtx_proto_rawDescOnce.Do(func() {
file_batchtx_proto_rawDescData = protoimpl.X.CompressGZIP(file_batchtx_proto_rawDescData)
})
return file_batchtx_proto_rawDescData
}
var file_batchtx_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_batchtx_proto_goTypes = []interface{}{
(*Tx)(nil), // 0: multisend.Tx
(*BatchTx)(nil), // 1: multisend.BatchTx
}
var file_batchtx_proto_depIdxs = []int32{
0, // 0: multisend.BatchTx.txs:type_name -> multisend.Tx
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_batchtx_proto_init() }
func file_batchtx_proto_init() {
if File_batchtx_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_batchtx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Tx); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_batchtx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BatchTx); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_batchtx_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_batchtx_proto_goTypes,
DependencyIndexes: file_batchtx_proto_depIdxs,
MessageInfos: file_batchtx_proto_msgTypes,
}.Build()
File_batchtx_proto = out.File
file_batchtx_proto_rawDesc = nil
file_batchtx_proto_goTypes = nil
file_batchtx_proto_depIdxs = nil
}
syntax = "proto3";
package multisend;
option go_package = "./";
message Tx{
bytes from = 1;
bytes to = 2;
int64 amount = 3;
}
message BatchTx{
bytes hash = 1;
repeated Tx txs = 2;
}
// message Person {
// string name = 1;
// int32 id = 2; // Unique ID number for this person.
// string email = 3;
// enum PhoneType {
// MOBILE = 0;
// HOME = 1;
// WORK = 2;
// }
// message PhoneNumber {
// string number = 1;
// PhoneType type = 2;
// }
// repeated PhoneNumber phones = 4;
// google.protobuf.Timestamp last_updated = 5;
// }
// // Our address book file is just one of these.
// message AddressBook {
// repeated Person people = 1;
// }
\ No newline at end of file
......@@ -16,14 +16,6 @@ import (
var sendTxPrivatekey string = "a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
var toAddress common.Address = common.HexToAddress("0x0071B39fd266F8aeF392fb50F078A233b2218a0b")
// func RegisterBuildTxParam(name string, factory Param) error {
// if _, exists := buildTxPrama[name]; exists {
// return fmt.Errorf("source param with the specified name already exists: %s", name)
// }
// buildTxPrama[name] = factory
// return nil
// }
func init() {
if err := RegisterClientFactory("ethclient", NewEthClientFactory()); err != nil {
panic(err)
......@@ -70,9 +62,6 @@ func (f *EthClientFactory) NewClient(cfg Config) (Client, error) {
PrivateKey: sendTxPrivatekeyAsECDSA,
FromAddr: sendTxFromAddress,
NodeUrl: "http://13.40.31.153:8545",
//https://heco.getblock.io/mainnet/
//NodeUrl: "https://heco.getblock.io/mainnet/",
//NodeUrl: "https://http-mainnet-node.huobichain.com",
}
cli, err := ethclient.Dial(buildTxParam.NodeUrl)
......
......@@ -3,10 +3,8 @@ package main
import (
"fmt"
"os"
"sync"
"code.wuban.net.cn/multisend"
"code.wuban.net.cn/multisend/internal/logging"
"github.com/spf13/cobra"
)
......@@ -27,17 +25,17 @@ func init() {
rootCmd.PersistentFlags().StringVar(&websocketAddr, "websocketAddr", "ws://13.40.31.153:8546", "eth classical websocket rpc addr")
rootCmd.PersistentFlags().IntVar(&rate, "rate", 1, "every period send tx number")
rootCmd.PersistentFlags().IntVar(&sendPeriod, "sendPeriod", 3, "send tx time unit")
rootCmd.PersistentFlags().IntVar(&count, "count", 100, "total tx number")
rootCmd.PersistentFlags().IntVar(&expectedTime, "expectedTime", 100, "the expected time used to send the total tx number")
rootCmd.PersistentFlags().IntVar(&count, "count", 1000, "total tx number")
rootCmd.PersistentFlags().IntVar(&expectedTime, "expectedTime", 3600, "the expected time used to send the total tx number")
rootCmd.PersistentFlags().StringVar(&redisAddr, "redisAddr", "127.0.0.1:6379", "commit the original txs to the redis queue")
rootCmd.PersistentFlags().StringVar(&redisPasswd, "redisPasswd", "redis20220217", "redis password")
}
var rootCmd = &cobra.Command{
Use: "sendTxs",
Short: "send batch txs hash to chain and original txs to redis",
Run: func(cmd *cobra.Command, args []string) {
logger := logging.NewLogrusLogger("cmd")
cfg := multisend.Config{
Rate: rate,
Count: count,
......@@ -50,21 +48,14 @@ var rootCmd = &cobra.Command{
transactor, err := multisend.NewTransactor(websocketAddr, &cfg)
if err != nil {
logger.Error(err.Error())
return
panic(err)
}
transactor.Start()
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
if err := multisend.ProduceOriginalTx(); err != nil {
logger.Error(err.Error())
return
panic(err)
}
}()
......
package multisend
import (
sync "sync"
"testing"
"time"
)
func TestTransactor(t *testing.T) {
go StartProduceTx("127.0.0.1:6379", "redis20220217")
//go StartProduceTx("127.0.0.1:6379", "redis20220217")
//for {
// if len(originalTxsHashQueue) >= 10 {
......@@ -36,6 +36,19 @@ func TestTransactor(t *testing.T) {
//transactor.sendLoop()
transactor.Start()
time.Sleep(time.Hour * 1)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
if err := ProduceOriginalTx(); err != nil {
t.Error(err.Error())
return
}
}()
Start("127.0.0.1:6379", "redis20220217")
}
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