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 ( ...@@ -11,11 +11,9 @@ const (
) )
// Info gets the info of the node. // 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{} res := &webapi_info.Response{}
if err := api.do(http.MethodGet, func() string { if err := api.do(http.MethodGet, routeInfo, nil, res); err != nil {
return routeInfo
}(), nil, res); err != nil {
return nil, err return nil, err
} }
return res, nil return res, nil
......
...@@ -20,5 +20,5 @@ var PLUGINS = node.Plugins( ...@@ -20,5 +20,5 @@ var PLUGINS = node.Plugins(
drng.PLUGIN, drng.PLUGIN,
message.PLUGIN, message.PLUGIN,
autopeering.PLUGIN, autopeering.PLUGIN,
info.PLUGIN, info.Plugin,
) )
...@@ -8,10 +8,10 @@ import ( ...@@ -8,10 +8,10 @@ import (
"github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"github.com/labstack/echo" "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) { func configure(plugin *node.Plugin) {
webapi.Server.GET("info", getInfo) webapi.Server.GET("info", getInfo)
...@@ -21,7 +21,7 @@ func configure(plugin *node.Plugin) { ...@@ -21,7 +21,7 @@ func configure(plugin *node.Plugin) {
// e.g., // e.g.,
// { // {
// "version":"v0.2.0", // "version":"v0.2.0",
// "identity":"7BxV1v3nFHefn4J88jeZebqnJRvSHt1jC7ME6tmKLhy7", // "identityID":"5bf4aa1d6c47e4ce",
// "publickey":"CjUsn86jpFHWnSCx3NhWfU4Lk16mDdy1Hr7ERSTv3xn9", // "publickey":"CjUsn86jpFHWnSCx3NhWfU4Lk16mDdy1Hr7ERSTv3xn9",
// "enabledplugins":[ // "enabledplugins":[
// "Config", // "Config",
...@@ -53,8 +53,8 @@ func configure(plugin *node.Plugin) { ...@@ -53,8 +53,8 @@ func configure(plugin *node.Plugin) {
// ] // ]
// } // }
func getInfo(c echo.Context) error { func getInfo(c echo.Context) error {
enabledPlugins := []string{} var enabledPlugins []string
disabledPlugins := []string{} var disabledPlugins []string
for plugin, status := range node.GetPlugins() { for plugin, status := range node.GetPlugins() {
switch status { switch status {
case node.Disabled: case node.Disabled:
...@@ -68,8 +68,8 @@ func getInfo(c echo.Context) error { ...@@ -68,8 +68,8 @@ func getInfo(c echo.Context) error {
return c.JSON(http.StatusOK, Response{ return c.JSON(http.StatusOK, Response{
Version: banner.AppVersion, Version: banner.AppVersion,
Identity: base58.Encode(local.GetInstance().Identity.ID().Bytes()), IdentityID: local.GetInstance().Identity.ID().String(),
PublicKey: base58.Encode(local.GetInstance().PublicKey().Bytes()), PublicKey: local.GetInstance().PublicKey().String(),
EnabledPlugins: enabledPlugins, EnabledPlugins: enabledPlugins,
DisabledPlugins: disabledPlugins, DisabledPlugins: disabledPlugins,
}) })
...@@ -79,8 +79,8 @@ func getInfo(c echo.Context) error { ...@@ -79,8 +79,8 @@ func getInfo(c echo.Context) error {
type Response struct { type Response struct {
// version of GoShimmer // version of GoShimmer
Version string `json:"version,omitempty"` Version string `json:"version,omitempty"`
// identity of the node encoded in base58 // identity ID of the node encoded in hex and truncated to its first 8 bytes
Identity string `json:"identity,omitempty"` IdentityID string `json:"identityID,omitempty"`
// public key of the node encoded in base58 // public key of the node encoded in base58
PublicKey string `json:"publickey,omitempty"` PublicKey string `json:"publickey,omitempty"`
// list of enabled plugins // 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