Skip to content
Snippets Groups Projects
Commit f1cb9270 authored by Luca Moser's avatar Luca Moser
Browse files

renames webapi endpoints

parent 65a91713
No related branches found
No related tags found
No related merge requests found
...@@ -10,10 +10,10 @@ import ( ...@@ -10,10 +10,10 @@ import (
"net/http" "net/http"
webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData"
webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes"
webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors"
webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash"
webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash"
webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta"
webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/iota.go/consts" "github.com/iotaledger/iota.go/consts"
...@@ -30,9 +30,9 @@ var ( ...@@ -30,9 +30,9 @@ var (
const ( const (
routeBroadcastData = "broadcastData" routeBroadcastData = "broadcastData"
routeGetTrytes = "getTrytes" routeGetTrytes = "getTransactionTrytesByHash"
routeGetTransactions = "getTransactions" routeGetTransactions = "getTransactionObjectsByHash"
routeFindTransactions = "findTransactions" routeFindTransactions = "findTransactionHashes"
routeGetNeighbors = "getNeighbors" routeGetNeighbors = "getNeighbors"
routeGetTransactionsToApprove = "getTransactionsToApprove" routeGetTransactionsToApprove = "getTransactionsToApprove"
routeSpammer = "spammer" routeSpammer = "spammer"
...@@ -107,7 +107,7 @@ func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string ...@@ -107,7 +107,7 @@ func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string
return resObj.Hash, nil return resObj.Hash, nil
} }
func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { func (api *GoShimmerAPI) GetTransactionTrytesByHash(txHashes trinary.Hashes) ([]trinary.Trytes, error) {
for _, hash := range txHashes { for _, hash := range txHashes {
if !guards.IsTrytes(hash) { if !guards.IsTrytes(hash) {
return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash)
...@@ -132,7 +132,7 @@ func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, e ...@@ -132,7 +132,7 @@ func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, e
return resObj.Trytes, nil return resObj.Trytes, nil
} }
func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { func (api *GoShimmerAPI) GetTransactionObjectsByHash(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) {
for _, hash := range txHashes { for _, hash := range txHashes {
if !guards.IsTrytes(hash) { if !guards.IsTrytes(hash) {
return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash)
...@@ -157,7 +157,7 @@ func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getT ...@@ -157,7 +157,7 @@ func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getT
return resObj.Transactions, nil return resObj.Transactions, nil
} }
func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { func (api *GoShimmerAPI) FindTransactionHashes(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) {
for _, hash := range query.Addresses { for _, hash := range query.Addresses {
if !guards.IsTrytes(hash) { if !guards.IsTrytes(hash) {
return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash)
......
...@@ -20,10 +20,10 @@ import ( ...@@ -20,10 +20,10 @@ import (
"github.com/iotaledger/goshimmer/plugins/ui" "github.com/iotaledger/goshimmer/plugins/ui"
"github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/goshimmer/plugins/webapi"
webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData"
webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" webapi_findTransactionHashes "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes"
webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors"
webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" webapi_getTransactionObjectsByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash"
webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" webapi_getTransactionTrytesByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash"
webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta"
webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/webauth"
...@@ -57,9 +57,9 @@ func main() { ...@@ -57,9 +57,9 @@ func main() {
webapi_gtta.PLUGIN, webapi_gtta.PLUGIN,
webapi_spammer.PLUGIN, webapi_spammer.PLUGIN,
webapi_broadcastData.PLUGIN, webapi_broadcastData.PLUGIN,
webapi_getTrytes.PLUGIN, webapi_getTransactionTrytesByHash.PLUGIN,
webapi_getTransactions.PLUGIN, webapi_getTransactionObjectsByHash.PLUGIN,
webapi_findTransactions.PLUGIN, webapi_findTransactionHashes.PLUGIN,
webapi_getNeighbors.PLUGIN, webapi_getNeighbors.PLUGIN,
webapi_spammer.PLUGIN, webapi_spammer.PLUGIN,
......
package findTransactions package findTransactionHashes
import ( import (
"net/http" "net/http"
...@@ -11,19 +11,19 @@ import ( ...@@ -11,19 +11,19 @@ import (
"github.com/labstack/echo" "github.com/labstack/echo"
) )
var PLUGIN = node.NewPlugin("WebAPI findTransactions Endpoint", node.Enabled, configure) var PLUGIN = node.NewPlugin("WebAPI findTransactionHashes Endpoint", node.Enabled, configure)
var log *logger.Logger var log *logger.Logger
func configure(plugin *node.Plugin) { func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-findTransactions") log = logger.NewLogger("API-findTransactionHashes")
webapi.Server.POST("findTransactions", findTransactions) webapi.Server.POST("findTransactionHashes", findTransactionHashes)
} }
// findTransactions returns the array of transaction hashes for the // findTransactionHashes returns the array of transaction hashes for the
// given addresses (in the same order as the parameters). // given addresses (in the same order as the parameters).
// If a node doesn't have any transaction hash for a given address in its ledger, // If a node doesn't have any transaction hash for a given address in its ledger,
// the value at the index of that address is empty. // the value at the index of that address is empty.
func findTransactions(c echo.Context) error { func findTransactionHashes(c echo.Context) error {
var request Request var request Request
if err := c.Bind(&request); err != nil { if err := c.Bind(&request); err != nil {
......
package getTransactions package getTransactionObjectsByHash
import ( import (
"net/http" "net/http"
...@@ -11,19 +11,19 @@ import ( ...@@ -11,19 +11,19 @@ import (
"github.com/labstack/echo" "github.com/labstack/echo"
) )
var PLUGIN = node.NewPlugin("WebAPI getTransaction Endpoint", node.Enabled, configure) var PLUGIN = node.NewPlugin("WebAPI getTransactionObjectsByHash Endpoint", node.Enabled, configure)
var log *logger.Logger var log *logger.Logger
func configure(plugin *node.Plugin) { func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-getTransactions") log = logger.NewLogger("API-getTransactionObjectsByHash")
webapi.Server.POST("getTransactions", getTransactions) webapi.Server.POST("getTransactionObjectsByHash", getTransactionObjectsByHash)
} }
// getTransactions returns the array of transactions for the // getTransactionObjectsByHash returns the array of transactions for the
// given transaction hashes (in the same order as the parameters). // given transaction hashes (in the same order as the parameters).
// If a node doesn't have the transaction for a given transaction hash in its ledger, // If a node doesn't have the transaction for a given transaction hash in its ledger,
// the value at the index of that transaction hash is empty. // the value at the index of that transaction hash is empty.
func getTransactions(c echo.Context) error { func getTransactionObjectsByHash(c echo.Context) error {
var request Request var request Request
result := []Transaction{} result := []Transaction{}
......
package getTrytes package getTransactionTrytesByHash
import ( import (
"net/http" "net/http"
...@@ -11,19 +11,19 @@ import ( ...@@ -11,19 +11,19 @@ import (
"github.com/labstack/echo" "github.com/labstack/echo"
) )
var PLUGIN = node.NewPlugin("WebAPI getTrytes Endpoint", node.Enabled, configure) var PLUGIN = node.NewPlugin("WebAPI getTransactionTrytesByHash Endpoint", node.Enabled, configure)
var log *logger.Logger var log *logger.Logger
func configure(plugin *node.Plugin) { func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-getTrytes") log = logger.NewLogger("API-getTransactionTrytesByHash")
webapi.Server.GET("getTrytes", getTrytes) webapi.Server.GET("getTransactionTrytesByHash", getTransactionTrytesByHash)
} }
// getTrytes returns the array of transaction trytes for the // getTransactionTrytesByHash returns the array of transaction trytes for the
// given transaction hashes (in the same order as the parameters). // given transaction hashes (in the same order as the parameters).
// If a node doesn't have the trytes for a given transaction hash in its ledger, // If a node doesn't have the trytes for a given transaction hash in its ledger,
// the value at the index of that transaction hash is empty. // the value at the index of that transaction hash is empty.
func getTrytes(c echo.Context) error { func getTransactionTrytesByHash(c echo.Context) error {
var request Request var request Request
result := []trinary.Trytes{} result := []trinary.Trytes{}
......
...@@ -19,7 +19,7 @@ func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { ...@@ -19,7 +19,7 @@ func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) {
func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error { func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error {
// query target node for broadcasted data // query target node for broadcasted data
_, err := api.GetTransactions([]trinary.Hash{txnHash}) _, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash})
if err != nil { if err != nil {
return errors.Wrapf(err, "Query target failed") return errors.Wrapf(err, "Query target failed")
} }
...@@ -30,7 +30,7 @@ func testNodesGetTransactions(txnHash trinary.Hash) error { ...@@ -30,7 +30,7 @@ func testNodesGetTransactions(txnHash trinary.Hash) error {
// query nodes node for broadcasted data // query nodes node for broadcasted data
for _, n := range nodes { for _, n := range nodes {
nodesApi := client.NewGoShimmerAPI(n) nodesApi := client.NewGoShimmerAPI(n)
_, err := nodesApi.GetTransactions([]trinary.Hash{txnHash}) _, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash})
if err != nil { if err != nil {
return errors.Wrapf(err, "Query %s failed", n) return errors.Wrapf(err, "Query %s failed", n)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment