diff --git a/client/lib.go b/client/lib.go index ed2884bab40a29d4d12e0c29835539ef644405a5..85084f5ae440cadddfcb3699944327339d81ad9f 100644 --- a/client/lib.go +++ b/client/lib.go @@ -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) diff --git a/main.go b/main.go index f7d202d11a105af72d69955a5a3b88e03a91c95a..319811df54bfd58cf595f9673cf8d838ff403157 100644 --- a/main.go +++ b/main.go @@ -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, diff --git a/plugins/webapi/findTransactions/plugin.go b/plugins/webapi/findTransactionHashes/plugin.go similarity index 80% rename from plugins/webapi/findTransactions/plugin.go rename to plugins/webapi/findTransactionHashes/plugin.go index ff9b406ad2af9af2d8f64b39e09fcf5970df146e..07a626d9fc7bbecea5b6a23e0f7d4f88849c6da9 100644 --- a/plugins/webapi/findTransactions/plugin.go +++ b/plugins/webapi/findTransactionHashes/plugin.go @@ -1,4 +1,4 @@ -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 { diff --git a/plugins/webapi/getTransactions/plugin.go b/plugins/webapi/getTransactionObjectsByHash/plugin.go similarity index 87% rename from plugins/webapi/getTransactions/plugin.go rename to plugins/webapi/getTransactionObjectsByHash/plugin.go index 70c231328b29c32e619e3c2b5927fac6c85c4557..221def3cdba855e876fdbaad72cb475dc38a6c1f 100644 --- a/plugins/webapi/getTransactions/plugin.go +++ b/plugins/webapi/getTransactionObjectsByHash/plugin.go @@ -1,4 +1,4 @@ -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{} diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTransactionTrytesByHash/plugin.go similarity index 79% rename from plugins/webapi/getTrytes/plugin.go rename to plugins/webapi/getTransactionTrytesByHash/plugin.go index b29b83fa76cb59a7dcf21093190dd75053eab477..b4bb36136d59cca735b790ed677f306e8e3d175c 100644 --- a/plugins/webapi/getTrytes/plugin.go +++ b/plugins/webapi/getTransactionTrytesByHash/plugin.go @@ -1,4 +1,4 @@ -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{} diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 189babf7ea79072579c5872a5209a9853989109a..18c1d1d9b5fa20d2d986120e3bf05495df9b7d93 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -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) }