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
8a0f2259
Commit
8a0f2259
authored
Mar 12, 2022
by
gshx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'heco-testnet' of
https://code.wuban.net.cn/liwei/multisend
into heco-testnet
parents
41a66ca8
72d31252
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
http.go
http.go
+68
-0
No files found.
http.go
View file @
8a0f2259
...
@@ -303,6 +303,72 @@ func (web *WebServicer) GetTxsList(w http.ResponseWriter, r *http.Request) {
...
@@ -303,6 +303,72 @@ func (web *WebServicer) GetTxsList(w http.ResponseWriter, r *http.Request) {
}
}
func
(
web
*
WebServicer
)
Calculate
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
requestAmountAsStr
:=
r
.
URL
.
Query
()
.
Get
(
"requestAmount"
)
currentAmountStr
:=
r
.
URL
.
Query
()
.
Get
(
"currentAmount"
)
everyTxAmountAsStr
:=
r
.
URL
.
Query
()
.
Get
(
"everyTxAmount"
)
txNumStr
:=
r
.
URL
.
Query
()
.
Get
(
"txNum"
)
requestAmountAsInt
,
err
:=
strconv
.
ParseInt
(
requestAmountAsStr
,
10
,
64
)
// if err != nil {
// http.Error(w, err.Error(), http.StatusBadRequest)
// return
// }
// currentAmount, err := strconv.ParseInt(currentAmountStr, 10, 64) // strconv.Atoi(currentAmountStr)
// if err != nil {
// http.Error(w, err.Error(), http.StatusBadRequest)
// return
// }
// everyTxAmountAsInt, err := strconv.ParseInt(everyTxAmountAsStr, 10, 64) // strconv.Atoi(everyTxAmountAsStr)
// if err != nil {
// http.Error(w, err.Error(), http.StatusBadRequest)
// return
// }
// txNum, err := strconv.ParseInt(txNumStr, 10, 64) //strconv.Atoi(txNumStr)
// if err != nil {
// http.Error(w, err.Error(), http.StatusBadRequest)
// return
// }
requestAmount
,
err
:=
decimal
.
NewFromString
(
requestAmountAsStr
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
currentAmount
,
err
:=
decimal
.
NewFromString
(
currentAmountStr
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
everyTxAmount
,
err
:=
decimal
.
NewFromString
(
everyTxAmountAsStr
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
txNum
,
err
:=
decimal
.
NewFromString
(
txNumStr
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
res
:=
requestAmount
.
Add
(
currentAmount
)
.
Sub
(
everyTxAmount
.
Mul
(
txNum
))
fmt
.
Printf
(
"len(resAsJson): %v
\n
"
,
res
.
String
())
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
Write
([]
byte
(
res
.
String
()))
}
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.
...
@@ -312,6 +378,8 @@ func (web *WebServicer) WebService(config Config) error {
...
@@ -312,6 +378,8 @@ func (web *WebServicer) WebService(config Config) error {
r
.
HandleFunc
(
"/sender/tree/{uuid}"
,
web
.
GetTreeHandler
)
r
.
HandleFunc
(
"/sender/tree/{uuid}"
,
web
.
GetTreeHandler
)
r
.
HandleFunc
(
"/sender/txslist/{hash}"
,
web
.
GetTxsList
)
r
.
HandleFunc
(
"/sender/txslist/{hash}"
,
web
.
GetTxsList
)
r
.
HandleFunc
(
"/sender/txs"
,
web
.
TxsHandler
)
.
Methods
(
"POST"
)
r
.
HandleFunc
(
"/sender/txs"
,
web
.
TxsHandler
)
.
Methods
(
"POST"
)
r
.
HandleFunc
(
"/sender/calculate"
,
web
.
Calculate
)
//r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(config.WebStaticDir))))
//r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(config.WebStaticDir))))
clientFactory
,
exists
:=
clientFactories
[
"ethclient"
]
clientFactory
,
exists
:=
clientFactories
[
"ethclient"
]
...
...
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