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
Show 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 (
var
(
initAcc
,
initCmp
,
batchSign
,
batchRecover
,
batchRecoverTx
,
batchVerify
bool
txCount
,
goRoutineCount
,
cmpAmount
int
txCount
,
goRoutineCount
,
cmpAmount
,
batchCount
int
cpuProfile
string
cfg
*
tool
.
Config
)
...
...
@@ -25,7 +25,8 @@ func init() {
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchRecoverTx
,
"batchRecoverTx"
,
false
,
"test grpc interface -> batchRecoverTx"
)
startCmd
.
PersistentFlags
()
.
BoolVar
(
&
batchVerify
,
"batchVerify"
,
false
,
"test grpc interface -> batchVerify"
)
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
)
}
...
...
startTest.go
View file @
ce0be510
...
...
@@ -20,6 +20,7 @@ func init() {
cfg
.
StorageAccFileName
+=
".xlsx"
cfg
.
GoRoutineCount
=
goRoutineCount
cfg
.
SignCount
=
txCount
/
100
cfg
.
BatchCount
=
batchCount
SendTxAccountArr
=
tool
.
ReadExcel
(
cfg
.
Count
,
cfg
.
StorageAccFileName
)
}
...
...
tool/Config.go
View file @
ce0be510
...
...
@@ -11,6 +11,7 @@ type Config struct {
ReceiveAddr
string
`json:"receiveAddr"`
Count
int
`json:"count"`
SignCount
int
`json:"signCount"`
BatchCount
int
`json:"batchCount"`
GoRoutineCount
int
`json:"goRoutineCount"`
Type
int
`json:"type"`
RpcNode
string
`json:"rpcNode"`
...
...
transaction/bathTest.go
View file @
ce0be510
...
...
@@ -252,6 +252,27 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
rawTxArr
:=
make
([]
*
v1
.
MetaTxBase
,
0
)
for
i
:=
0
;
i
<
int
(
allSignedTxCount
);
i
++
{
tran
:=
tranArr
[
i
]
rawTx
:=
constructionRawTx
(
tran
)
rawTxArr
=
append
(
rawTxArr
,
&
rawTx
)
if
len
(
rawTxArr
)
==
cfg
.
BatchCount
{
req
:=
crypterv1
.
BatchRecoverTxRequest
{
RawTx
:
rawTxArr
,
}
batchRecoverTxRequest
<-
&
req
rawTxArr
=
make
([]
*
v1
.
MetaTxBase
,
0
)
}
}
for
{
if
bathHandleSendCount
==
allSignedTxCount
/
int64
(
cfg
.
BatchCount
)
{
log
.
Infof
(
"Send tran count: %d"
,
bathHandleSendCount
)
log
.
Infof
(
"Since time: %d ms"
,
time
.
Since
(
startTime
)
.
Milliseconds
())
break
}
}
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
())
...
...
@@ -276,21 +297,5 @@ func BatchRecoverTxHandler(tranArr []*types.Transaction, cfg *tool.Config) error
S
:
ns
,
TxHash
:
&
hash
,
}
rawTxArr
=
append
(
rawTxArr
,
&
rawTx
)
req
:=
crypterv1
.
BatchRecoverTxRequest
{
RawTx
:
rawTxArr
,
}
if
len
(
rawTxArr
)
==
cfg
.
SignCount
{
batchRecoverTxRequest
<-
&
req
rawTxArr
=
make
([]
*
v1
.
MetaTxBase
,
0
)
}
}
for
{
if
bathHandleSendCount
==
allSignedTxCount
/
int64
(
cfg
.
SignCount
)
{
log
.
Infof
(
"Send tran count: %d"
,
bathHandleSendCount
)
log
.
Infof
(
"Since time: %d ms"
,
time
.
Since
(
startTime
)
.
Milliseconds
())
break
}
}
return
nil
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