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
f711527d
Commit
f711527d
authored
Feb 21, 2022
by
李伟@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1s send 1 tx
parent
64c2cd69
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
31 deletions
+33
-31
client_eth.go
client_eth.go
+26
-24
transactor.go
transactor.go
+1
-1
transactor_test.go
transactor_test.go
+6
-6
No files found.
client_eth.go
View file @
f711527d
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"github.com/go-redis/redis/v8"
"github.com/go-redis/redis/v8"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
...
@@ -21,15 +20,15 @@ import (
...
@@ -21,15 +20,15 @@ import (
var
privatekey
string
=
"a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
var
privatekey
string
=
"a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
var
toAddress
common
.
Address
=
common
.
HexToAddress
(
"0x4592d8f8d7b001e72cb26a73e4fa1806a51ac79d"
)
var
toAddress
common
.
Address
=
common
.
HexToAddress
(
"0x4592d8f8d7b001e72cb26a73e4fa1806a51ac79d"
)
// var data []byte = make([]byte, 0, md5.Size*(1000
))
var
data
[]
byte
=
make
([]
byte
,
0
,
md5
.
Size
*
(
3
))
//
func init() {
func
init
()
{
//
privatekey = "a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
privatekey
=
"a1994419e9b06a7b27e8d094840ae26a6b7806633bb8be55a1a835f1620d8cec"
// for i := 0; i < 8140
; i++ {
for
i
:=
0
;
i
<
3
;
i
++
{
//
hash := md5.Sum([]byte(fmt.Sprintf("%d", i)))
hash
:=
md5
.
Sum
([]
byte
(
fmt
.
Sprintf
(
"%d"
,
i
)))
//
data = append(data, hash[:]...)
data
=
append
(
data
,
hash
[
:
]
...
)
//
}
}
//
}
}
type
EthClientFactory
struct
{}
type
EthClientFactory
struct
{}
...
@@ -61,6 +60,7 @@ func (f *EthClientFactory) NewClient(cfg Config) (Client, error) {
...
@@ -61,6 +60,7 @@ func (f *EthClientFactory) NewClient(cfg Config) (Client, error) {
}
}
func
(
c
*
EthClient
)
GenerateTx
()
(
*
types
.
Transaction
,
error
)
{
func
(
c
*
EthClient
)
GenerateTx
()
(
*
types
.
Transaction
,
error
)
{
privateKeyAsECDSA
,
err
:=
crypto
.
HexToECDSA
(
privatekey
)
privateKeyAsECDSA
,
err
:=
crypto
.
HexToECDSA
(
privatekey
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -81,27 +81,29 @@ func (c *EthClient) GenerateTx() (*types.Transaction, error) {
...
@@ -81,27 +81,29 @@ func (c *EthClient) GenerateTx() (*types.Transaction, error) {
return
nil
,
err
return
nil
,
err
}
}
gasPrice
,
err
:=
client
.
SuggestGasPrice
(
context
.
Background
())
//
gasPrice, err := client.SuggestGasPrice(context.Background())
if
err
!=
nil
{
//
if err != nil {
return
nil
,
err
//
return nil, err
}
//
}
chainID
,
err
:=
client
.
NetworkID
(
context
.
Background
())
//
chainID, err := client.NetworkID(context.Background())
if
err
!=
nil
{
//
if err != nil {
return
nil
,
err
//
return nil, err
}
//
}
txs
,
md5data
,
err
:=
getBatchTx
(
100
,
c
.
NodeRpcURL
,
false
)
txs
,
md5data
,
err
:=
getBatchTx
(
3
,
c
.
NodeRpcURL
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
_
=
txs
_
=
txs
gasLimit
,
err
:=
client
.
EstimateGas
(
context
.
Background
(),
ethereum
.
CallMsg
{
//
gasLimit, err := client.EstimateGas(context.Background(), ethereum.CallMsg{
To
:
&
toAddress
,
//
To: &toAddress,
Data
:
md5data
,
//
Data: md5data,
})
//
})
tx
:=
types
.
NewTransaction
(
nonce
,
toAddress
,
big
.
NewInt
(
10000000000000
),
gasLimit
,
gasPrice
,
md5data
)
//fmt.Printf("gasLimit: %d gasPrice: %d \n", gasLimit, gasPrice)
signedTx
,
err
:=
types
.
SignTx
(
tx
,
types
.
NewEIP155Signer
(
chainID
),
privateKeyAsECDSA
)
tx
:=
types
.
NewTransaction
(
nonce
,
toAddress
,
big
.
NewInt
(
10000000000000
),
24894
,
big
.
NewInt
(
1000000000
),
md5data
)
//tx := types.NewTransaction(nonce, toAddress, big.NewInt(10000000000000), 24894, big.NewInt(1000000000), data)
signedTx
,
err
:=
types
.
SignTx
(
tx
,
types
.
NewEIP155Signer
(
big
.
NewInt
(
256
)),
privateKeyAsECDSA
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
transactor.go
View file @
f711527d
...
@@ -250,7 +250,7 @@ func (t *Transactor) sendTransactions() error {
...
@@ -250,7 +250,7 @@ func (t *Transactor) sendTransactions() error {
var
sent
int
var
sent
int
var
sentBytes
int64
var
sentBytes
int64
defer
func
()
{
t
.
trackSentTxs
(
sent
,
sentBytes
)
}()
defer
func
()
{
t
.
trackSentTxs
(
sent
,
sentBytes
)
}()
t
.
logger
.
Info
(
"Sending batch of transactions"
,
"toSend"
,
toSend
)
t
.
logger
.
Info
(
"Sending batch of transactions"
,
"
now"
,
time
.
Now
()
.
Format
(
"15:04:05"
),
"
toSend"
,
toSend
)
batchStartTime
:=
time
.
Now
()
batchStartTime
:=
time
.
Now
()
for
;
sent
<
toSend
;
sent
++
{
for
;
sent
<
toSend
;
sent
++
{
tx
,
err
:=
t
.
client
.
GenerateTx
()
tx
,
err
:=
t
.
client
.
GenerateTx
()
...
...
transactor_test.go
View file @
f711527d
...
@@ -8,11 +8,11 @@ import (
...
@@ -8,11 +8,11 @@ import (
func
TestTransactor
(
t
*
testing
.
T
)
{
func
TestTransactor
(
t
*
testing
.
T
)
{
cfg
:=
Config
{
cfg
:=
Config
{
Rate
:
10
,
Rate
:
2
,
Count
:
10
,
Count
:
10
0
,
Connections
:
1
,
Connections
:
1
,
Time
:
6
0
,
Time
:
10
0
,
SendPeriod
:
1
0
,
SendPeriod
:
1
,
ClientFactory
:
"ethclient"
,
ClientFactory
:
"ethclient"
,
}
}
...
@@ -21,9 +21,9 @@ func TestTransactor(t *testing.T) {
...
@@ -21,9 +21,9 @@ func TestTransactor(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
transactor
.
sendTransactions
()
//
transactor.sendTransactions()
//transactor.sendLoop()
//transactor.sendLoop()
//
transactor.Start()
transactor
.
Start
()
time
.
Sleep
(
time
.
Second
*
60
)
time
.
Sleep
(
time
.
Second
*
60
)
...
...
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