Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
cc52696d
Unverified
Commit
cc52696d
authored
4 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
Fix webapi linter warnings
parent
5dec0554
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/message.go
+2
-2
2 additions, 2 deletions
client/message.go
plugins/webapi/message/sendPayload.go
+9
-9
9 additions, 9 deletions
plugins/webapi/message/sendPayload.go
with
11 additions
and
11 deletions
client/message.go
+
2
−
2
View file @
cc52696d
...
@@ -30,9 +30,9 @@ func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_mes
...
@@ -30,9 +30,9 @@ func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_mes
// SendPayload send a message with the given payload.
// SendPayload send a message with the given payload.
func
(
api
*
GoShimmerAPI
)
SendPayload
(
payload
[]
byte
)
(
string
,
error
)
{
func
(
api
*
GoShimmerAPI
)
SendPayload
(
payload
[]
byte
)
(
string
,
error
)
{
res
:=
&
webapi_message
.
M
essage
Response
{}
res
:=
&
webapi_message
.
M
sg
Response
{}
if
err
:=
api
.
do
(
http
.
MethodPost
,
routeSendPayload
,
if
err
:=
api
.
do
(
http
.
MethodPost
,
routeSendPayload
,
&
webapi_message
.
M
essage
Request
{
Payload
:
payload
},
res
);
err
!=
nil
{
&
webapi_message
.
M
sg
Request
{
Payload
:
payload
},
res
);
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/message/sendPayload.go
+
9
−
9
View file @
cc52696d
...
@@ -11,34 +11,34 @@ import (
...
@@ -11,34 +11,34 @@ import (
// sendPayload creates a message of the given payload and
// sendPayload creates a message of the given payload and
// broadcasts it to the node's neighbors. It returns the message ID if successful.
// broadcasts it to the node's neighbors. It returns the message ID if successful.
func
sendPayload
(
c
echo
.
Context
)
error
{
func
sendPayload
(
c
echo
.
Context
)
error
{
var
request
M
essage
Request
var
request
M
sg
Request
if
err
:=
c
.
Bind
(
&
request
);
err
!=
nil
{
if
err
:=
c
.
Bind
(
&
request
);
err
!=
nil
{
log
.
Info
(
err
.
Error
())
log
.
Info
(
err
.
Error
())
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
essage
Response
{
Error
:
err
.
Error
()})
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
sg
Response
{
Error
:
err
.
Error
()})
}
}
//TODO: to check max payload size allowed, if exceeding return an error
//TODO: to check max payload size allowed, if exceeding return an error
parsedPayload
,
_
,
err
:=
payload
.
FromBytes
(
request
.
Payload
)
parsedPayload
,
_
,
err
:=
payload
.
FromBytes
(
request
.
Payload
)
if
err
!=
nil
{
if
err
!=
nil
{
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
essage
Response
{
Error
:
"not a valid payload"
})
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
sg
Response
{
Error
:
"not a valid payload"
})
}
}
msg
,
err
:=
issuer
.
IssuePayload
(
parsedPayload
)
msg
,
err
:=
issuer
.
IssuePayload
(
parsedPayload
)
if
err
!=
nil
{
if
err
!=
nil
{
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
essage
Response
{
Error
:
err
.
Error
()})
return
c
.
JSON
(
http
.
StatusBadRequest
,
M
sg
Response
{
Error
:
err
.
Error
()})
}
}
return
c
.
JSON
(
http
.
StatusOK
,
M
essage
Response
{
ID
:
msg
.
Id
()
.
String
()})
return
c
.
JSON
(
http
.
StatusOK
,
M
sg
Response
{
ID
:
msg
.
Id
()
.
String
()})
}
}
// M
essage
Response contains the ID of the message sent.
// M
sg
Response contains the ID of the message sent.
type
M
essage
Response
struct
{
type
M
sg
Response
struct
{
ID
string
`json:"id,omitempty"`
ID
string
`json:"id,omitempty"`
Error
string
`json:"error,omitempty"`
Error
string
`json:"error,omitempty"`
}
}
// M
essage
Request contains the message to send.
// M
sg
Request contains the message to send.
type
M
essage
Request
struct
{
type
M
sg
Request
struct
{
Payload
[]
byte
`json:"payload"`
Payload
[]
byte
`json:"payload"`
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment