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
b10fa6d8
Commit
b10fa6d8
authored
5 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
adds more fields to the info api
parent
ba5058e8
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
plugins/drng/drng.go
+2
-2
2 additions, 2 deletions
plugins/drng/drng.go
plugins/webapi/info/plugin.go
+68
-3
68 additions, 3 deletions
plugins/webapi/info/plugin.go
with
70 additions
and
5 deletions
plugins/drng/drng.go
+
2
−
2
View file @
b10fa6d8
package
drng
import
(
"encoding/hex"
"errors"
"fmt"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/mr-tron/base58/base58"
)
var
(
...
...
@@ -20,7 +20,7 @@ func parseCommitteeMembers() (result []ed25519.PublicKey, err error) {
continue
}
pubKey
,
err
:=
hex
.
Decode
String
(
committeeMember
)
pubKey
,
err
:=
base58
.
Decode
(
committeeMember
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"%w: invalid public key: %s"
,
ErrParsingCommitteeMember
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/info/plugin.go
+
68
−
3
View file @
b10fa6d8
package
info
import
(
"encoding/hex"
"net/http"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/banner"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/node"
"github.com/labstack/echo"
"github.com/mr-tron/base58"
)
var
PLUGIN
=
node
.
NewPlugin
(
"WebAPI info Endpoint"
,
node
.
Enabled
,
configure
)
...
...
@@ -17,11 +18,75 @@ func configure(plugin *node.Plugin) {
}
// getInfo returns the info of the node
// e.g.,
// {
// "version":"v0.2.0",
// "identity":"7BxV1v3nFHefn4J88jeZebqnJRvSHt1jC7ME6tmKLhy7",
// "publickey":"CjUsn86jpFHWnSCx3NhWfU4Lk16mDdy1Hr7ERSTv3xn9",
// "enabledplugins":[
// "Config",
// "Autopeering",
// "Analysis",
// "WebAPI data Endpoint",
// "WebAPI dRNG Endpoint",
// "MessageLayer",
// "CLI",
// "Database",
// "DRNG",
// "WebAPI autopeering Endpoint",
// "Metrics",
// "PortCheck",
// "SPA",
// "WebAPI",
// "WebAPI info Endpoint",
// "WebAPI message Endpoint",
// "Banner",
// "Gossip",
// "Graceful Shutdown",
// "Logger"
// ],
// "disabledlugins":[
// "Graph",
// "RemoteLog",
// "Spammer",
// "WebAPI Auth"
// ]
// }
func
getInfo
(
c
echo
.
Context
)
error
{
return
c
.
JSON
(
http
.
StatusOK
,
Response
{
PublicKey
:
hex
.
EncodeToString
(
local
.
GetInstance
()
.
PublicKey
()
.
Bytes
())})
enabledPlugins
:=
[]
string
{}
disabledPlugins
:=
[]
string
{}
for
plugin
,
status
:=
range
node
.
GetPlugins
()
{
switch
status
{
case
node
.
Disabled
:
disabledPlugins
=
append
(
disabledPlugins
,
plugin
)
case
node
.
Enabled
:
enabledPlugins
=
append
(
enabledPlugins
,
plugin
)
default
:
continue
}
}
return
c
.
JSON
(
http
.
StatusOK
,
Response
{
Version
:
banner
.
AppVersion
,
Identity
:
base58
.
Encode
(
local
.
GetInstance
()
.
Identity
.
ID
()
.
Bytes
()),
PublicKey
:
base58
.
Encode
(
local
.
GetInstance
()
.
PublicKey
()
.
Bytes
()),
EnabledPlugins
:
enabledPlugins
,
DisabledPlugins
:
disabledPlugins
,
})
}
// Response holds the response of the GET request.
type
Response
struct
{
// version of GoShimmer
Version
string
`json:"version,omitempty"`
// identity of the node encoded in base58
Identity
string
`json:"identity,omitempty"`
// public key of the node encoded in base58
PublicKey
string
`json:"publickey,omitempty"`
Error
string
`json:"error,omitempty"`
// list of enabled plugins
EnabledPlugins
[]
string
`json:"enabledplugins,omitempty"`
// list if disabled plugins
DisabledPlugins
[]
string
`json:"disabledlugins,omitempty"`
// error of the response
Error
string
`json:"error,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