Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ChainGrpcPro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanjinfei
ChainGrpcPro
Commits
ce0be510
Commit
ce0be510
authored
Mar 09, 2023
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add batch send tx count
parent
a5410c05
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
31 deletions
+39
-31
main.go
main.go
+3
-2
startTest.go
startTest.go
+1
-0
Config.go
tool/Config.go
+1
-0
bathTest.go
transaction/bathTest.go
+34
-29
No files found.
main.go
View file @
ce0be510
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
var
(
var
(
initAcc
,
initCmp
,
batchSign
,
batchRecover
,
batchRecoverTx
,
batchVerify
bool
initAcc
,
initCmp
,
batchSign
,
batchRecover
,
batchRecoverTx
,
batchVerify
bool
txCount
,
goRoutineCount
,
cmpAmount
int
txCount
,
goRoutineCount
,
cmpAmount
,
batchCount
int
cpuProfile
string
cpuProfile
string
cfg
*
tool
.
Config
cfg
*
tool
.
Config
)
)
...
@@ -25,7 +25,8 @@ func init() {
...
@@ -25,7 +25,8 @@ func init() {
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchRecoverTx
,
"batchRecoverTx"
,
false
,
"test grpc interface -> batchRecoverTx"
)
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchRecoverTx
,
"batchRecoverTx"
,
false
,
"test grpc interface -> batchRecoverTx"
)
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchVerify
,
"batchVerify"
,
false
,
"test grpc interface -> batchVerify"
)
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchVerify
,
"batchVerify"
,
false
,
"test grpc interface -> batchVerify"
)
startCmd
.
PersistentFlags
()
.
IntVar
(
&
txCount
,
"txCount"
,
1000
,
"send tran count"
)
startCmd
.
PersistentFlags
()
.
IntVar
(
&
txCount
,
"txCount"
,
1000
,
"send tran count"
)
startCmd
.
PersistentFlags
()
.
IntVar
(
&
goRoutineCount
,
"goRoutineCount"
,
100
,
"send tran engagement count"
)
startCmd
.
PersistentFlags
()
.
IntVar
(
&
goRoutineCount
,
"goRoutineCount"
,
100
,
"send tran goRoutine count"
)
startCmd
.
PersistentFlags
()
.
IntVar
(
&
batchCount
,
"batchCount"
,
100
,
"batch send tran count"
)
startCmd
.
AddCommand
(
initCmd
)
startCmd
.
AddCommand
(
initCmd
)
}
}
...
...
startTest.go
View file @
ce0be510
...
@@ -20,6 +20,7 @@ func init() {
...
@@ -20,6 +20,7 @@ func init() {
cfg
.
StorageAccFileName
+=
".xlsx"
cfg
.
StorageAccFileName
+=
".xlsx"
cfg
.
GoRoutineCount
=
goRoutineCount
cfg
.
GoRoutineCount
=
goRoutineCount
cfg
.
SignCount
=
txCount
/
100
cfg
.
SignCount
=
txCount
/
100
cfg
.
BatchCount
=
batchCount
SendTxAccountArr
=
tool
.
ReadExcel
(
cfg
.
Count
,
cfg
.
StorageAccFileName
)
SendTxAccountArr
=
tool
.
ReadExcel
(
cfg
.
Count
,
cfg
.
StorageAccFileName
)
}
}
...
...
tool/Config.go
View file @
ce0be510
...
@@ -11,6 +11,7 @@ type Config struct {
...
@@ -11,6 +11,7 @@ type Config struct {
ReceiveAddr
string
`json:"receiveAddr"`
ReceiveAddr
string
`json:"receiveAddr"`
Count
int
`json:"count"`
Count
int
`json:"count"`
SignCount
int
`json:"signCount"`
SignCount
int
`json:"signCount"`
BatchCount
int
`json:"batchCount"`
GoRoutineCount
int
`json:"goRoutineCount"`
GoRoutineCount
int
`json:"goRoutineCount"`
Type
int
`json:"type"`
Type
int
`json:"type"`
RpcNode
string
`json:"rpcNode"`
RpcNode
string
`json:"rpcNode"`
...
...
transaction/bathTest.go
View file @
ce0be510
...
@@ -252,41 +252,18 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
...
@@ -252,41 +252,18 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
rawTxArr
:=
make
([]
*
v1
.
MetaTxBase
,
0
)
rawTxArr
:=
make
([]
*
v1
.
MetaTxBase
,
0
)
for
i
:=
0
;
i
<
int
(
allSignedTxCount
);
i
++
{
for
i
:=
0
;
i
<
int
(
allSignedTxCount
);
i
++
{
tran
:=
tranArr
[
i
]
tran
:=
tranArr
[
i
]
v
,
r
,
s
:=
tran
.
RawSignatureValues
()
rawTx
:=
constructionRawTx
(
tran
)
toAddr
:=
metatypes
.
BytesToAddress
(
tran
.
To
()
.
Bytes
())
hash
:=
metatypes
.
HexToHash
(
tran
.
Hash
()
.
Hex
())
nv
:=
metatypes
.
NewBigInt
(
0
)
nv
.
Set
(
v
)
nr
:=
metatypes
.
NewBigInt
(
0
)
nr
.
Set
(
r
)
ns
:=
metatypes
.
NewBigInt
(
0
)
ns
.
Set
(
s
)
rawTx
:=
v1
.
MetaTxBase
{
TxType
:
uint32
(
tran
.
Type
()),
ChainId
:
metatypes
.
NewBigInt
(
tran
.
ChainId
()
.
Int64
()),
Nonce
:
tran
.
Nonce
(),
GasPrice
:
metatypes
.
NewBigInt
(
tran
.
GasPrice
()
.
Int64
()),
Gas
:
tran
.
Gas
(),
To
:
&
toAddr
,
Value
:
metatypes
.
NewBigInt
(
tran
.
Value
()
.
Int64
()),
Data
:
tran
.
Data
(),
AccessList
:
nil
,
V
:
nv
,
R
:
nr
,
S
:
ns
,
TxHash
:
&
hash
,
}
rawTxArr
=
append
(
rawTxArr
,
&
rawTx
)
rawTxArr
=
append
(
rawTxArr
,
&
rawTx
)
req
:=
crypterv1
.
BatchRecoverTxRequest
{
if
len
(
rawTxArr
)
==
cfg
.
BatchCount
{
RawTx
:
rawTxArr
,
req
:=
crypterv1
.
BatchRecoverTxRequest
{
}
RawTx
:
rawTxArr
,
if
len
(
rawTxArr
)
==
cfg
.
SignCount
{
}
batchRecoverTxRequest
<-
&
req
batchRecoverTxRequest
<-
&
req
rawTxArr
=
make
([]
*
v1
.
MetaTxBase
,
0
)
rawTxArr
=
make
([]
*
v1
.
MetaTxBase
,
0
)
}
}
}
}
for
{
for
{
if
bathHandleSendCount
==
allSignedTxCount
/
int64
(
cfg
.
Sign
Count
)
{
if
bathHandleSendCount
==
allSignedTxCount
/
int64
(
cfg
.
Batch
Count
)
{
log
.
Infof
(
"Send tran count: %d"
,
bathHandleSendCount
)
log
.
Infof
(
"Send tran count: %d"
,
bathHandleSendCount
)
log
.
Infof
(
"Since time: %d ms"
,
time
.
Since
(
startTime
)
.
Milliseconds
())
log
.
Infof
(
"Since time: %d ms"
,
time
.
Since
(
startTime
)
.
Milliseconds
())
break
break
...
@@ -294,3 +271,31 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
...
@@ -294,3 +271,31 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
}
}
return
nil
return
nil
}
}
func
constructionRawTx
(
tran
*
types
.
Transaction
)
v1
.
MetaTxBase
{
v
,
r
,
s
:=
tran
.
RawSignatureValues
()
toAddr
:=
metatypes
.
BytesToAddress
(
tran
.
To
()
.
Bytes
())
hash
:=
metatypes
.
HexToHash
(
tran
.
Hash
()
.
Hex
())
nv
:=
metatypes
.
NewBigInt
(
0
)
nv
.
Set
(
v
)
nr
:=
metatypes
.
NewBigInt
(
0
)
nr
.
Set
(
r
)
ns
:=
metatypes
.
NewBigInt
(
0
)
ns
.
Set
(
s
)
rawTx
:=
v1
.
MetaTxBase
{
TxType
:
uint32
(
tran
.
Type
()),
ChainId
:
metatypes
.
NewBigInt
(
tran
.
ChainId
()
.
Int64
()),
Nonce
:
tran
.
Nonce
(),
GasPrice
:
metatypes
.
NewBigInt
(
tran
.
GasPrice
()
.
Int64
()),
Gas
:
tran
.
Gas
(),
To
:
&
toAddr
,
Value
:
metatypes
.
NewBigInt
(
tran
.
Value
()
.
Int64
()),
Data
:
tran
.
Data
(),
AccessList
:
nil
,
V
:
nv
,
R
:
nr
,
S
:
ns
,
TxHash
:
&
hash
,
}
return
rawTx
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment