Skip to content
Snippets Groups Projects
Commit 54866b13 authored by Hans Moog's avatar Hans Moog
Browse files

Refactor: uncommented broken code

parent 49b59250
No related branches found
No related tags found
No related merge requests found
package getTransactionObjectsByHash package getTransactionObjectsByHash
import ( import (
"fmt"
"net/http" "net/http"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"github.com/iotaledger/iota.go/trinary" "github.com/iotaledger/iota.go/trinary"
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/iotaledger/goshimmer/plugins/webapi"
) )
var PLUGIN = node.NewPlugin("WebAPI getTransactionObjectsByHash Endpoint", node.Enabled, configure) var PLUGIN = node.NewPlugin("WebAPI getTransactionObjectsByHash Endpoint", node.Enabled, configure)
...@@ -34,30 +34,31 @@ func getTransactionObjectsByHash(c echo.Context) error { ...@@ -34,30 +34,31 @@ func getTransactionObjectsByHash(c echo.Context) error {
} }
log.Debug("Received:", request.Hashes) log.Debug("Received:", request.Hashes)
/*
for _, hash := range request.Hashes { for _, hash := range request.Hashes {
tx, err := tangle_old.GetTransaction(hash) tx, err := tangle_old.GetTransaction(hash)
if err != nil { if err != nil {
return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) 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}) return c.JSON(http.StatusOK, Response{Transactions: result})
} }
......
package getTransactionTrytesByHash package getTransactionTrytesByHash
import ( import (
"fmt"
"net/http" "net/http"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"github.com/iotaledger/iota.go/trinary" "github.com/iotaledger/iota.go/trinary"
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/iotaledger/goshimmer/plugins/webapi"
) )
var PLUGIN = node.NewPlugin("WebAPI getTransactionTrytesByHash Endpoint", node.Enabled, configure) var PLUGIN = node.NewPlugin("WebAPI getTransactionTrytesByHash Endpoint", node.Enabled, configure)
...@@ -33,17 +33,19 @@ func getTransactionTrytesByHash(c echo.Context) error { ...@@ -33,17 +33,19 @@ func getTransactionTrytesByHash(c echo.Context) error {
} }
log.Debug("Received:", request.Hashes) log.Debug("Received:", request.Hashes)
for _, hash := range request.Hashes { /*
tx, err := tangle_old.GetTransaction(hash) for _, hash := range request.Hashes {
if err != nil { tx, err := tangle_old.GetTransaction(hash)
return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) 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}) return c.JSON(http.StatusOK, Response{Trytes: result})
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment