Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multisend
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
李伟@五瓣科技
multisend
Commits
42718ddf
Commit
42718ddf
authored
Mar 01, 2022
by
李伟@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
send tx private key as cmd param
parent
94a698f6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
12 deletions
+15
-12
client_eth.go
client_eth.go
+1
-2
root.go
cmd/root.go
+9
-7
config.go
config.go
+1
-0
redis.go
redis.go
+4
-3
No files found.
client_eth.go
View file @
42718ddf
...
...
@@ -13,7 +13,6 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)
var
sendTxPrivatekey
string
=
"a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
var
toAddress
common
.
Address
=
common
.
HexToAddress
(
"0x0071B39fd266F8aeF392fb50F078A233b2218a0b"
)
func
init
()
{
...
...
@@ -47,7 +46,7 @@ func (f *EthClientFactory) ValidateConfig(cfg Config) error {
func
(
f
*
EthClientFactory
)
NewClient
(
cfg
Config
)
(
Client
,
error
)
{
sendTxPrivatekeyAsECDSA
,
err
:=
crypto
.
HexToECDSA
(
sendTxPrivatek
ey
)
sendTxPrivatekeyAsECDSA
,
err
:=
crypto
.
HexToECDSA
(
cfg
.
SendTxPrivateK
ey
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
cmd/root.go
View file @
42718ddf
...
...
@@ -18,6 +18,7 @@ func Execute() {
var
(
rate
,
sendPeriod
,
count
,
expectedTime
int
websocketAddr
,
redisAddr
,
redisPasswd
string
sendTxPrivateKey
string
)
func
init
()
{
...
...
@@ -29,7 +30,7 @@ func init() {
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"
)
rootCmd
.
PersistentFlags
()
.
StringVar
(
&
sendTxPrivateKey
,
"sendTxPrivateKey"
,
"a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
,
"send tx to the chain with the private key"
)
}
var
rootCmd
=
&
cobra
.
Command
{
...
...
@@ -43,6 +44,7 @@ var rootCmd = &cobra.Command{
Time
:
int
(
expectedTime
),
SendPeriod
:
int
(
sendPeriod
),
ClientFactory
:
"ethclient"
,
SendTxPrivateKey
:
sendTxPrivateKey
,
}
transactor
,
err
:=
multisend
.
NewTransactor
(
websocketAddr
,
&
cfg
)
...
...
config.go
View file @
42718ddf
...
...
@@ -36,6 +36,7 @@ type Config struct {
PeerConnectTimeout
int
`json:"peer_connect_timeout"`
// The maximum time to wait (in seconds) for all peers to connect, if ExpectPeers > 0.
StatsOutputFile
string
`json:"stats_output_file"`
// Where to store the final aggregate statistics file (in CSV format).
NoTrapInterrupts
bool
`json:"no_trap_interrupts"`
// Should we avoid trapping Ctrl+Break? Only relevant for standalone execution mode.
SendTxPrivateKey
string
`json:"send_tx_private_key"`
// Send tx to the chain with the private key.
}
var
validBroadcastTxMethods
=
map
[
string
]
interface
{}{
...
...
redis.go
View file @
42718ddf
...
...
@@ -3,6 +3,7 @@ package multisend
import
(
"context"
"encoding/json"
"fmt"
//"fmt"
"runtime"
...
...
@@ -15,8 +16,6 @@ import (
var
(
jobnum
=
runtime
.
NumCPU
()
loggerRedis
=
logging
.
NewLogrusLogger
(
"redis"
)
)
type
Job
struct
{
...
...
@@ -44,6 +43,8 @@ func initClient(poolSize int, redisAddr, passwd string) *redis.Client {
func
Start
(
redisAddr
,
passwd
string
)
{
logger
:=
logging
.
NewLogrusLogger
(
fmt
.
Sprintf
(
"redis[%s]"
,
redisAddr
))
client
:=
initClient
(
10
,
redisAddr
,
passwd
)
count
:=
0
limiter
:=
rate
.
NewLimiter
(
rate
.
Every
(
time
.
Millisecond
*
100
),
1
)
...
...
@@ -68,7 +69,7 @@ func Start(redisAddr, passwd string) {
count
+=
1
case
<-
logTicker
.
C
:
logger
Redis
.
Info
(
"Sending batchTxs to redis"
,
"idx"
,
count
,
"toRedis"
,
redisAddr
,
"totaltxsCount"
,
batchTxSize
*
count
,
"now"
,
time
.
Now
()
.
Format
(
"15:04:05"
))
logger
.
Info
(
"Sending batchTxs to redis"
,
"idx"
,
count
,
"totaltxsCount"
,
batchTxSize
*
count
,
"now"
,
time
.
Now
()
.
Format
(
"15:04:05"
))
}
}
...
...
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