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
9130c7ea
Commit
9130c7ea
authored
Mar 11, 2022
by
李伟@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add calculate
parent
d5340652
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
http.go
http.go
+44
-0
No files found.
http.go
View file @
9130c7ea
...
@@ -303,6 +303,48 @@ func (web *WebServicer) GetTxsList(w http.ResponseWriter, r *http.Request) {
...
@@ -303,6 +303,48 @@ 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
}
res
:=
decimal
.
NewFromInt
(
requestAmountAsInt
)
.
Add
(
decimal
.
NewFromInt
(
currentAmount
))
.
Sub
(
decimal
.
NewFromInt
(
everyTxAmountAsInt
)
.
Mul
(
decimal
.
NewFromInt
(
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 +354,8 @@ func (web *WebServicer) WebService(config Config) error {
...
@@ -312,6 +354,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