From d2b9e0f324cb02a9ffb9ec520b4e04ff4579ba09 Mon Sep 17 00:00:00 2001 From: capossele <angelocapossele@gmail.com> Date: Fri, 17 Apr 2020 13:58:02 +0100 Subject: [PATCH] :ok_hand: Updating code due to code review changes. --- client/info.go | 6 ++---- pluginmgr/webapi/plugins.go | 2 +- plugins/webapi/info/plugin.go | 18 +++++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/client/info.go b/client/info.go index 85b10515..08c43ae6 100644 --- a/client/info.go +++ b/client/info.go @@ -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 diff --git a/pluginmgr/webapi/plugins.go b/pluginmgr/webapi/plugins.go index 76f1df75..464d058c 100644 --- a/pluginmgr/webapi/plugins.go +++ b/pluginmgr/webapi/plugins.go @@ -20,5 +20,5 @@ var PLUGINS = node.Plugins( drng.PLUGIN, message.PLUGIN, autopeering.PLUGIN, - info.PLUGIN, + info.Plugin, ) diff --git a/plugins/webapi/info/plugin.go b/plugins/webapi/info/plugin.go index 1d8c3d04..e2ae0357 100644 --- a/plugins/webapi/info/plugin.go +++ b/plugins/webapi/info/plugin.go @@ -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 -- GitLab