Skip to content
Snippets Groups Projects
Commit d2b9e0f3 authored by capossele's avatar capossele
Browse files

:ok_hand:

Updating code due to code review changes.
parent b10fa6d8
Branches
Tags
No related merge requests found
......@@ -11,11 +11,9 @@ const (
)
// Info gets the info of the node.
func (api *GoShimmerAPI) Info(knownPeers bool) (*webapi_info.Response, error) {
func (api *GoShimmerAPI) Info() (*webapi_info.Response, error) {
res := &webapi_info.Response{}
if err := api.do(http.MethodGet, func() string {
return routeInfo
}(), nil, res); err != nil {
if err := api.do(http.MethodGet, routeInfo, nil, res); err != nil {
return nil, err
}
return res, nil
......
......@@ -20,5 +20,5 @@ var PLUGINS = node.Plugins(
drng.PLUGIN,
message.PLUGIN,
autopeering.PLUGIN,
info.PLUGIN,
info.Plugin,
)
......@@ -8,10 +8,10 @@ import (
"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)
// Plugin exports the plugin
var Plugin = node.NewPlugin("WebAPI info Endpoint", node.Enabled, configure)
func configure(plugin *node.Plugin) {
webapi.Server.GET("info", getInfo)
......@@ -21,7 +21,7 @@ func configure(plugin *node.Plugin) {
// e.g.,
// {
// "version":"v0.2.0",
// "identity":"7BxV1v3nFHefn4J88jeZebqnJRvSHt1jC7ME6tmKLhy7",
// "identityID":"5bf4aa1d6c47e4ce",
// "publickey":"CjUsn86jpFHWnSCx3NhWfU4Lk16mDdy1Hr7ERSTv3xn9",
// "enabledplugins":[
// "Config",
......@@ -53,8 +53,8 @@ func configure(plugin *node.Plugin) {
// ]
// }
func getInfo(c echo.Context) error {
enabledPlugins := []string{}
disabledPlugins := []string{}
var enabledPlugins []string
var disabledPlugins []string
for plugin, status := range node.GetPlugins() {
switch status {
case node.Disabled:
......@@ -68,8 +68,8 @@ func getInfo(c echo.Context) error {
return c.JSON(http.StatusOK, Response{
Version: banner.AppVersion,
Identity: base58.Encode(local.GetInstance().Identity.ID().Bytes()),
PublicKey: base58.Encode(local.GetInstance().PublicKey().Bytes()),
IdentityID: local.GetInstance().Identity.ID().String(),
PublicKey: local.GetInstance().PublicKey().String(),
EnabledPlugins: enabledPlugins,
DisabledPlugins: disabledPlugins,
})
......@@ -79,8 +79,8 @@ func getInfo(c echo.Context) error {
type Response struct {
// version of GoShimmer
Version string `json:"version,omitempty"`
// identity of the node encoded in base58
Identity string `json:"identity,omitempty"`
// identity ID of the node encoded in hex and truncated to its first 8 bytes
IdentityID string `json:"identityID,omitempty"`
// public key of the node encoded in base58
PublicKey string `json:"publickey,omitempty"`
// list of enabled plugins
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment