From 54866b13dfd84745d1117f0de929930ca6b0463b Mon Sep 17 00:00:00 2001 From: Hans Moog <hm@mkjc.net> Date: Sat, 22 Feb 2020 17:19:29 +0100 Subject: [PATCH] Refactor: uncommented broken code --- .../getTransactionObjectsByHash/plugin.go | 51 ++++++++++--------- .../getTransactionTrytesByHash/plugin.go | 26 +++++----- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/plugins/webapi/getTransactionObjectsByHash/plugin.go b/plugins/webapi/getTransactionObjectsByHash/plugin.go index 7a7d6265..042ec469 100644 --- a/plugins/webapi/getTransactionObjectsByHash/plugin.go +++ b/plugins/webapi/getTransactionObjectsByHash/plugin.go @@ -1,14 +1,14 @@ package getTransactionObjectsByHash import ( - "fmt" "net/http" - "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" "github.com/labstack/echo" + + "github.com/iotaledger/goshimmer/plugins/webapi" ) var PLUGIN = node.NewPlugin("WebAPI getTransactionObjectsByHash Endpoint", node.Enabled, configure) @@ -34,30 +34,31 @@ func getTransactionObjectsByHash(c echo.Context) error { } log.Debug("Received:", request.Hashes) - - for _, hash := range request.Hashes { - tx, err := tangle_old.GetTransaction(hash) - if err != nil { - return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) + /* + for _, hash := range request.Hashes { + tx, err := tangle_old.GetTransaction(hash) + if err != nil { + return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) + } + if tx == nil { + return c.JSON(http.StatusNotFound, Response{Error: fmt.Sprintf("transaction not found: %s", hash)}) + } + t := Transaction{ + Hash: tx.GetHash(), + WeightMagnitude: tx.GetWeightMagnitude(), + TrunkTransactionHash: tx.GetTrunkTransactionHash(), + BranchTransactionHash: tx.GetBranchTransactionHash(), + Head: tx.IsHead(), + Tail: tx.IsTail(), + Nonce: tx.GetNonce(), + Address: tx.GetAddress(), + Value: tx.GetValue(), + Timestamp: tx.GetTimestamp(), + SignatureMessageFragment: tx.GetSignatureMessageFragment(), + } + result = append(result, t) } - if tx == nil { - return c.JSON(http.StatusNotFound, Response{Error: fmt.Sprintf("transaction not found: %s", hash)}) - } - t := Transaction{ - Hash: tx.GetHash(), - WeightMagnitude: tx.GetWeightMagnitude(), - TrunkTransactionHash: tx.GetTrunkTransactionHash(), - BranchTransactionHash: tx.GetBranchTransactionHash(), - Head: tx.IsHead(), - Tail: tx.IsTail(), - Nonce: tx.GetNonce(), - Address: tx.GetAddress(), - Value: tx.GetValue(), - Timestamp: tx.GetTimestamp(), - SignatureMessageFragment: tx.GetSignatureMessageFragment(), - } - result = append(result, t) - } + */ return c.JSON(http.StatusOK, Response{Transactions: result}) } diff --git a/plugins/webapi/getTransactionTrytesByHash/plugin.go b/plugins/webapi/getTransactionTrytesByHash/plugin.go index 4775dcd4..bfa94613 100644 --- a/plugins/webapi/getTransactionTrytesByHash/plugin.go +++ b/plugins/webapi/getTransactionTrytesByHash/plugin.go @@ -1,14 +1,14 @@ package getTransactionTrytesByHash import ( - "fmt" "net/http" - "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" "github.com/labstack/echo" + + "github.com/iotaledger/goshimmer/plugins/webapi" ) var PLUGIN = node.NewPlugin("WebAPI getTransactionTrytesByHash Endpoint", node.Enabled, configure) @@ -33,17 +33,19 @@ func getTransactionTrytesByHash(c echo.Context) error { } log.Debug("Received:", request.Hashes) - for _, hash := range request.Hashes { - tx, err := tangle_old.GetTransaction(hash) - if err != nil { - return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) + /* + for _, hash := range request.Hashes { + tx, err := tangle_old.GetTransaction(hash) + if err != nil { + return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) + } + if tx == nil { + return c.JSON(http.StatusNotFound, Response{Error: fmt.Sprintf("transaction not found: %s", hash)}) + } + trytes := trinary.MustTritsToTrytes(tx.GetTrits()) + result = append(result, trytes) } - if tx == nil { - return c.JSON(http.StatusNotFound, Response{Error: fmt.Sprintf("transaction not found: %s", hash)}) - } - trytes := trinary.MustTritsToTrytes(tx.GetTrits()) - result = append(result, trytes) - } + */ return c.JSON(http.StatusOK, Response{Trytes: result}) } -- GitLab