Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
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
iota-imt
goshimmer
Commits
6f949637
Unverified
Commit
6f949637
authored
5 years ago
by
Angelo Capossele
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #366 from iotaledger/refactor/remove_getMessageByHash
refactor: Remove web api getMessageByHash
parents
af691344
e55d1983
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/webapi/getMessageByHash/plugin.go
+0
-92
0 additions, 92 deletions
plugins/webapi/getMessageByHash/plugin.go
with
0 additions
and
92 deletions
plugins/webapi/getMessageByHash/plugin.go
deleted
100644 → 0
+
0
−
92
View file @
af691344
package
getMessageByHash
import
(
"net/http"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/labstack/echo"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
)
// PluginName is the name of the web API getMessageByHash endpoint plugin.
const
PluginName
=
"WebAPI getMessageByHash Endpoint"
var
(
// Plugin is the plugin instance of the web API getMessageByHash endpoint plugin.
Plugin
=
node
.
NewPlugin
(
PluginName
,
node
.
Enabled
,
configure
)
log
*
logger
.
Logger
)
func
configure
(
plugin
*
node
.
Plugin
)
{
log
=
logger
.
NewLogger
(
"API-getMessageByHash"
)
webapi
.
Server
.
POST
(
"getMessageByHash"
,
getMessageByHash
)
}
// getMessageByHash returns the array of messages for the
// given message hashes (in the same order as the parameters).
// If a node doesn't have the message for a given message hash in its ledger,
// the value at the index of that message hash is empty.
func
getMessageByHash
(
c
echo
.
Context
)
error
{
var
request
Request
if
err
:=
c
.
Bind
(
&
request
);
err
!=
nil
{
log
.
Info
(
err
.
Error
())
return
c
.
JSON
(
http
.
StatusBadRequest
,
Response
{
Error
:
err
.
Error
()})
}
var
result
[]
Message
for
_
,
hash
:=
range
request
.
Hashes
{
log
.
Info
(
"Received:"
,
hash
)
msgId
,
err
:=
message
.
NewId
(
hash
)
if
err
!=
nil
{
log
.
Info
(
err
)
continue
}
msgObject
:=
messagelayer
.
Tangle
.
Message
(
msgId
)
if
!
msgObject
.
Exists
()
{
continue
}
msg
:=
msgObject
.
Unwrap
()
msgResp
:=
Message
{
MessageId
:
msg
.
Id
()
.
String
(),
TrunkMessageId
:
msg
.
TrunkId
()
.
String
(),
BranchMessageId
:
msg
.
BranchId
()
.
String
(),
IssuerPublicKey
:
msg
.
IssuerPublicKey
()
.
String
(),
IssuingTime
:
msg
.
IssuingTime
()
.
String
(),
SequenceNumber
:
msg
.
SequenceNumber
(),
Payload
:
msg
.
Payload
()
.
String
(),
Signature
:
msg
.
Signature
()
.
String
(),
}
result
=
append
(
result
,
msgResp
)
msgObject
.
Release
()
}
return
c
.
JSON
(
http
.
StatusOK
,
Response
{
Messages
:
result
})
}
type
Response
struct
{
Messages
[]
Message
`json:"messages,omitempty"`
Error
string
`json:"error,omitempty"`
}
type
Request
struct
{
Hashes
[]
string
`json:"hashes"`
}
type
Message
struct
{
MessageId
string
`json:"messageId,omitempty"`
TrunkMessageId
string
`json:"trunkMessageId,omitempty"`
BranchMessageId
string
`json:"branchMessageId,omitempty"`
IssuerPublicKey
string
`json:"issuerPublicKey,omitempty"`
IssuingTime
string
`json:"issuingTime,omitempty"`
SequenceNumber
uint64
`json:"sequenceNumber,omitempty"`
Payload
string
`json:"payload,omitempty"`
Signature
string
`json:"signature,omitempty"`
}
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