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 (
"net/http"
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_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions"
webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes"
webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash"
webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash"
webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta"
webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/iota.go/consts"
......@@ -30,9 +30,9 @@ var (
const (
routeBroadcastData = "broadcastData"
routeGetTrytes = "getTrytes"
routeGetTransactions = "getTransactions"
routeFindTransactions = "findTransactions"
routeGetTrytes = "getTransactionTrytesByHash"
routeGetTransactions = "getTransactionObjectsByHash"
routeFindTransactions = "findTransactionHashes"
routeGetNeighbors = "getNeighbors"
routeGetTransactionsToApprove = "getTransactionsToApprove"
routeSpammer = "spammer"
......@@ -107,7 +107,7 @@ func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string
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 {
if !guards.IsTrytes(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
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 {
if !guards.IsTrytes(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
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 {
if !guards.IsTrytes(hash) {
return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash)
......
......@@ -20,10 +20,10 @@ import (
"github.com/iotaledger/goshimmer/plugins/ui"
"github.com/iotaledger/goshimmer/plugins/webapi"
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_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions"
webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes"
webapi_getTransactionObjectsByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash"
webapi_getTransactionTrytesByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash"
webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta"
webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/goshimmer/plugins/webauth"
......@@ -57,9 +57,9 @@ func main() {
webapi_gtta.PLUGIN,
webapi_spammer.PLUGIN,
webapi_broadcastData.PLUGIN,
webapi_getTrytes.PLUGIN,
webapi_getTransactions.PLUGIN,
webapi_findTransactions.PLUGIN,
webapi_getTransactionTrytesByHash.PLUGIN,
webapi_getTransactionObjectsByHash.PLUGIN,
webapi_findTransactionHashes.PLUGIN,
webapi_getNeighbors.PLUGIN,
webapi_spammer.PLUGIN,
......
package findTransactions
package findTransactionHashes
import (
"net/http"
......@@ -11,19 +11,19 @@ import (
"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
func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-findTransactions")
webapi.Server.POST("findTransactions", findTransactions)
log = logger.NewLogger("API-findTransactionHashes")
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).
// 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.
func findTransactions(c echo.Context) error {
func findTransactionHashes(c echo.Context) error {
var request Request
if err := c.Bind(&request); err != nil {
......
package getTransactions
package getTransactionObjectsByHash
import (
"net/http"
......@@ -11,19 +11,19 @@ import (
"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
func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-getTransactions")
webapi.Server.POST("getTransactions", getTransactions)
log = logger.NewLogger("API-getTransactionObjectsByHash")
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).
// 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.
func getTransactions(c echo.Context) error {
func getTransactionObjectsByHash(c echo.Context) error {
var request Request
result := []Transaction{}
......
package getTrytes
package getTransactionTrytesByHash
import (
"net/http"
......@@ -11,19 +11,19 @@ import (
"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
func configure(plugin *node.Plugin) {
log = logger.NewLogger("API-getTrytes")
webapi.Server.GET("getTrytes", getTrytes)
log = logger.NewLogger("API-getTransactionTrytesByHash")
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).
// 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.
func getTrytes(c echo.Context) error {
func getTransactionTrytesByHash(c echo.Context) error {
var request Request
result := []trinary.Trytes{}
......
......@@ -19,7 +19,7 @@ func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) {
func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error {
// query target node for broadcasted data
_, err := api.GetTransactions([]trinary.Hash{txnHash})
_, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash})
if err != nil {
return errors.Wrapf(err, "Query target failed")
}
......@@ -30,7 +30,7 @@ func testNodesGetTransactions(txnHash trinary.Hash) error {
// query nodes node for broadcasted data
for _, n := range nodes {
nodesApi := client.NewGoShimmerAPI(n)
_, err := nodesApi.GetTransactions([]trinary.Hash{txnHash})
_, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash})
if err != nil {
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