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
608a54d4
Commit
608a54d4
authored
Mar 04, 2022
by
李伟@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update prama
parent
f06024aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
http.go
http.go
+30
-6
originalTx.go
originalTx.go
+5
-2
transactor.go
transactor.go
+3
-2
No files found.
http.go
View file @
608a54d4
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"math/big"
"math/big"
"net/http"
"net/http"
"strconv"
"strconv"
"sync/atomic"
"sync"
"sync"
...
@@ -20,6 +21,7 @@ import (
...
@@ -20,6 +21,7 @@ import (
var
mnemonic
=
"matter someone fee garlic final police during vapor stool cargo snake dove"
var
mnemonic
=
"matter someone fee garlic final police during vapor stool cargo snake dove"
var
processMap
sync
.
Map
var
processMap
sync
.
Map
var
Running
int32
=
0
func
GetSendRecord
(
id
uuid
.
UUID
)
(
SendRecord
,
bool
)
{
func
GetSendRecord
(
id
uuid
.
UUID
)
(
SendRecord
,
bool
)
{
...
@@ -53,7 +55,11 @@ type WebServicer struct {
...
@@ -53,7 +55,11 @@ type WebServicer struct {
cli
Client
cli
Client
}
}
func
(
web
*
WebServicer
)
AddressHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
const
MaxToAddrsNum
=
1000
const
MaxTxCount
=
5
*
1000
*
1000
const
MaxRequestAmount
=
MaxTxCount
*
10
func
(
web
*
WebServicer
)
ParamHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
wallet
,
err
:=
hdwallet
.
NewFromMnemonic
(
mnemonic
)
wallet
,
err
:=
hdwallet
.
NewFromMnemonic
(
mnemonic
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -61,10 +67,17 @@ func (web *WebServicer) AddressHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -61,10 +67,17 @@ func (web *WebServicer) AddressHandler(w http.ResponseWriter, r *http.Request) {
}
}
resp
:=
struct
{
resp
:=
struct
{
From
string
`json:"from"`
From
string
`json:"from"`
ToAddrs
[]
string
`json:"to_addrs"`
ToAddrs
[]
string
`json:"to_addrs"`
MaxToAddrsNum
int64
`json:"max_to_addrs_num"`
MaxRequestAmount
int64
`json:"max_request_amount"`
MaxTxCount
int64
`json:"max_tx_count"`
}{}
}{}
resp
.
MaxToAddrsNum
=
MaxToAddrsNum
resp
.
MaxTxCount
=
MaxTxCount
resp
.
MaxRequestAmount
=
MaxRequestAmount
for
i
:=
0
;
i
<=
1000
;
i
++
{
for
i
:=
0
;
i
<=
1000
;
i
++
{
path
:=
hdwallet
.
MustParseDerivationPath
(
fmt
.
Sprintf
(
"m/44'/60'/0'/0/%d"
,
i
))
path
:=
hdwallet
.
MustParseDerivationPath
(
fmt
.
Sprintf
(
"m/44'/60'/0'/0/%d"
,
i
))
...
@@ -99,7 +112,7 @@ func (web *WebServicer) AddressHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -99,7 +112,7 @@ func (web *WebServicer) AddressHandler(w http.ResponseWriter, r *http.Request) {
func
(
web
*
WebServicer
)
WebService
(
config
Config
)
error
{
func
(
web
*
WebServicer
)
WebService
(
config
Config
)
error
{
r
:=
mux
.
NewRouter
()
r
:=
mux
.
NewRouter
()
// Routes consist of a path and a handler function.
// Routes consist of a path and a handler function.
r
.
HandleFunc
(
"/
addrs"
,
web
.
Address
Handler
)
r
.
HandleFunc
(
"/
param"
,
web
.
Param
Handler
)
//r.HandleFunc("/faucet/{addr}", web.FaucetHandler)
//r.HandleFunc("/faucet/{addr}", web.FaucetHandler)
r
.
HandleFunc
(
"/process/{uuid}"
,
web
.
ProcessHandler
)
r
.
HandleFunc
(
"/process/{uuid}"
,
web
.
ProcessHandler
)
r
.
HandleFunc
(
"/txs"
,
web
.
TxsHandler
)
.
Methods
(
"POST"
)
r
.
HandleFunc
(
"/txs"
,
web
.
TxsHandler
)
.
Methods
(
"POST"
)
...
@@ -215,9 +228,20 @@ func (web *WebServicer) TxsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -215,9 +228,20 @@ func (web *WebServicer) TxsHandler(w http.ResponseWriter, r *http.Request) {
return
return
}
}
if
atomic
.
LoadInt32
(
&
Running
)
!=
0
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"another batch txs is running "
),
http
.
StatusBadRequest
)
return
}
atomic
.
StoreInt32
(
&
Running
,
1
)
// 有余额的话,金额不好判断,由前端校验;
// 有余额的话,金额不好判断,由前端校验;
// if params.EveryTxAmount * params.TxCount < params.RequestAmount{
if
params
.
EveryTxAmount
*
params
.
TxCount
<
params
.
RequestAmount
&&
params
.
RequestAmount
>
5
*
1000
*
1000
{
// }
http
.
Error
(
w
,
fmt
.
Sprintf
(
"params.EveryTxAmount*params.TxCount < params.RequestAmount && params.RequestAmount > 5*1000*1000"
),
http
.
StatusBadRequest
)
return
}
//startTime := time.Now()
//startTime := time.Now()
...
...
originalTx.go
View file @
608a54d4
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"crypto/sha256"
"crypto/sha256"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/google/uuid"
"github.com/google/uuid"
...
@@ -25,8 +26,10 @@ const batchTxHashSize = 3
...
@@ -25,8 +26,10 @@ const batchTxHashSize = 3
const
batchTxHashQueueSize
=
10
const
batchTxHashQueueSize
=
10
type
ConTxsWithId
struct
{
type
ConTxsWithId
struct
{
Id
uuid
.
UUID
SendRedisTime
time
.
Time
Tx
*
types
.
Transaction
OriginalTx
common
.
Hash
Id
uuid
.
UUID
Tx
*
types
.
Transaction
}
}
type
OriginalBatchTxs
struct
{
type
OriginalBatchTxs
struct
{
...
...
transactor.go
View file @
608a54d4
...
@@ -269,7 +269,7 @@ func (t *Transactor) sendTransactions() error {
...
@@ -269,7 +269,7 @@ func (t *Transactor) sendTransactions() error {
args
:=
hexutil
.
Encode
(
data
)
args
:=
hexutil
.
Encode
(
data
)
method
:=
"eth_sendRawTransaction"
method
:=
"eth_sendRawTransaction"
fmt
.
Printf
(
"
\n
%s
\n
"
,
args
)
t
.
logger
.
Info
(
"send tx"
,
"idx"
,
sent
,
"TxAsHex
"
,
args
)
msg
,
err
:=
t
.
newMessage
(
method
,
args
)
msg
,
err
:=
t
.
newMessage
(
method
,
args
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -285,10 +285,11 @@ func (t *Transactor) sendTransactions() error {
...
@@ -285,10 +285,11 @@ func (t *Transactor) sendTransactions() error {
//return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(data))
//return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(data))
// if we have to make way for the next batch
// if we have to make way for the next batch
if
time
.
Since
(
batchStartTime
)
>=
time
.
Duration
(
t
.
config
.
SendPeriod
)
*
time
.
Second
{
if
time
.
Since
(
batchStartTime
)
>=
time
.
Duration
(
t
.
config
.
SendPeriod
)
*
time
.
Second
{
fmt
.
Printf
(
"time.Since(batchStartTime): %s
\n
"
,
fmt
.
Sprintf
(
"%.20f
"
,
time
.
Since
(
batchStartTime
)
.
Seconds
()))
t
.
logger
.
Info
(
"send batch txs timeout"
,
"time.Since(batchStartTime)"
,
fmt
.
Sprintf
(
"%.20f s
"
,
time
.
Since
(
batchStartTime
)
.
Seconds
()))
break
break
}
}
default
:
default
:
atomic
.
StoreInt32
(
&
Running
,
0
)
t
.
logger
.
Info
(
"there is no tx in queue"
,
"now"
,
time
.
Now
()
.
Format
(
"15:04:05"
))
t
.
logger
.
Info
(
"there is no tx in queue"
,
"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