diff --git a/client/lib.go b/client/lib.go index 9f2da12438e084b097a11712fce31d194df26f9b..bcdae11cdad5c84d78710158b5219f202534be48 100644 --- a/client/lib.go +++ b/client/lib.go @@ -1,5 +1,5 @@ // Implements a very simple wrapper for GoShimmer's web API . -package goshimmer +package client import ( "bytes" @@ -11,16 +11,10 @@ import ( "net/http" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" - webapi_findTransactionHashes "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" + webapi_findMessageById "github.com/iotaledger/goshimmer/plugins/webapi/findMessageById" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" - 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" webapi_auth "github.com/iotaledger/goshimmer/plugins/webauth" - "github.com/iotaledger/iota.go/consts" - "github.com/iotaledger/iota.go/guards" - "github.com/iotaledger/iota.go/trinary" ) var ( @@ -33,14 +27,12 @@ var ( ) const ( - routeBroadcastData = "broadcastData" - routeGetTransactionTrytesByHash = "getTransactionTrytesByHash" - routeGetTransactionObjectsByHash = "getTransactionObjectsByHash" - routeFindTransactionsHashes = "findTransactionHashes" - routeGetNeighbors = "getNeighbors" - routeGetTransactionsToApprove = "getTransactionsToApprove" - routeSpammer = "spammer" - routeLogin = "login" + routeBroadcastData = "broadcastData" + routeGetMessageById = "getMessageById" + routeGetNeighbors = "getNeighbors" + routeSpammer = "spammer" + routeLogin = "login" + //routeGetTransactionsToApprove = "getTransactionsToApprove" contentTypeJSON = "application/json" ) @@ -156,68 +148,31 @@ func (api *GoShimmerAPI) Login(username string, password string) error { } // BroadcastData sends the given data by creating a zero value transaction in the backend targeting the given address. -func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string) (trinary.Hash, error) { - if !guards.IsHash(targetAddress) { - return "", fmt.Errorf("%w: invalid address: %s", consts.ErrInvalidHash, targetAddress) - } +func (api *GoShimmerAPI) BroadcastData(data []byte) (string, error) { res := &webapi_broadcastData.Response{} if err := api.do(http.MethodPost, routeBroadcastData, - &webapi_broadcastData.Request{Address: targetAddress, Data: data}, res); err != nil { + &webapi_broadcastData.Request{Data: data}, res); err != nil { return "", err } - return res.Hash, nil + return res.Id, nil } -// GetTransactionTrytesByHash gets the corresponding transaction trytes given the transaction hashes. -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) - } - } +func (api *GoShimmerAPI) FindMessageById(base58EncodedIds []string) (*webapi_findMessageById.Response, error) { + res := &webapi_findMessageById.Response{} - res := &webapi_getTransactionTrytesByHash.Response{} - if err := api.do(http.MethodPost, routeGetTransactionTrytesByHash, - &webapi_getTransactionTrytesByHash.Request{Hashes: txHashes}, res); err != nil { - return nil, err - } - - return res.Trytes, nil -} - -// GetTransactionObjectsByHash gets the transaction objects given the transaction hashes. -func (api *GoShimmerAPI) GetTransactionObjectsByHash(txHashes trinary.Hashes) ([]webapi_getTransactionObjectsByHash.Transaction, error) { - for _, hash := range txHashes { - if !guards.IsTrytes(hash) { - return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) - } - } - - res := &webapi_getTransactionObjectsByHash.Response{} - if err := api.do(http.MethodPost, routeGetTransactionObjectsByHash, - &webapi_getTransactionObjectsByHash.Request{Hashes: txHashes}, res); err != nil { - return nil, err - } - - return res.Transactions, nil -} - -// FindTransactionHashes finds the given transaction hashes given the query. -func (api *GoShimmerAPI) FindTransactionHashes(query *webapi_findTransactionHashes.Request) ([]trinary.Hashes, error) { - for _, hash := range query.Addresses { - if !guards.IsTrytes(hash) { - return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) - } - } - - res := &webapi_findTransactionHashes.Response{} - if err := api.do(http.MethodPost, routeFindTransactionsHashes, query, res); err != nil { + err := api.do( + http.MethodPost, + routeGetMessageById, + &webapi_findMessageById.Request{Ids: base58EncodedIds}, + res, + ) + if err != nil { return nil, err } - return res.Transactions, nil + return res, nil } // GetNeighbors gets the chosen/accepted neighbors. @@ -235,14 +190,14 @@ func (api *GoShimmerAPI) GetNeighbors(knownPeers bool) (*webapi_getNeighbors.Res return res, nil } -// GetTips executes the tip-selection on the node to retrieve tips to approve. -func (api *GoShimmerAPI) GetTransactionsToApprove() (*webapi_gtta.Response, error) { - res := &webapi_gtta.Response{} - if err := api.do(http.MethodGet, routeGetTransactionsToApprove, nil, res); err != nil { - return nil, err - } - return res, nil -} +// // GetTips executes the tip-selection on the node to retrieve tips to approve. +// func (api *GoShimmerAPI) GetTransactionsToApprove() (*webapi_gtta.Response, error) { +// res := &webapi_gtta.Response{} +// if err := api.do(http.MethodGet, routeGetTransactionsToApprove, nil, res); err != nil { +// return nil, err +// } +// return res, nil +// } // ToggleSpammer toggles the node internal spammer. func (api *GoShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { diff --git a/pluginmgr/webapi/plugins.go b/pluginmgr/webapi/plugins.go index 0caf419e0e971fb37836105f2e7d1678fa9cd281..dca728c1df58880f59b3d7df9c9699fda7162e3f 100644 --- a/pluginmgr/webapi/plugins.go +++ b/pluginmgr/webapi/plugins.go @@ -3,11 +3,8 @@ package webapi import ( "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" - "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" + "github.com/iotaledger/goshimmer/plugins/webapi/findMessageById" "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" - "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash" - "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" - "github.com/iotaledger/goshimmer/plugins/webapi/gtta" "github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/hive.go/node" @@ -16,11 +13,9 @@ import ( var PLUGINS = node.Plugins( webapi.PLUGIN, webauth.PLUGIN, - gtta.PLUGIN, + //gtta.PLUGIN, spammer.PLUGIN, broadcastData.PLUGIN, - getTransactionTrytesByHash.PLUGIN, - getTransactionObjectsByHash.PLUGIN, - findTransactionHashes.PLUGIN, + findMessageById.PLUGIN, getNeighbors.PLUGIN, ) diff --git a/plugins/webapi/broadcastData/plugin.go b/plugins/webapi/broadcastData/plugin.go index 5b854be601f187a57d74a302a6b0fad5b737d1af..b67903fbba6ae925ada4be40f042a772c9fe59b3 100644 --- a/plugins/webapi/broadcastData/plugin.go +++ b/plugins/webapi/broadcastData/plugin.go @@ -19,8 +19,8 @@ func configure(plugin *node.Plugin) { webapi.Server.POST("broadcastData", broadcastData) } -// broadcastData creates a data (0-value) transaction given an input of bytes and -// broadcasts it to the node's neighbors. It returns the transaction hash if successful. +// broadcastData creates a message of the given payload and +// broadcasts it to the node's neighbors. It returns the message ID if successful. func broadcastData(c echo.Context) error { var request Request if err := c.Bind(&request); err != nil { @@ -28,17 +28,18 @@ func broadcastData(c echo.Context) error { return c.JSON(http.StatusBadRequest, Response{Error: err.Error()}) } - tx := messagelayer.MessageFactory.IssuePayload(payload.NewData([]byte(request.Data))) + //TODO: to check max payload size allowed, if exceeding return an error - return c.JSON(http.StatusOK, Response{Hash: tx.Id().String()}) + tx := messagelayer.MessageFactory.IssuePayload(payload.NewData(request.Data)) + + return c.JSON(http.StatusOK, Response{Id: tx.Id().String()}) } type Response struct { - Hash string `json:"hash,omitempty"` + Id string `json:"id,omitempty"` Error string `json:"error,omitempty"` } type Request struct { - Address string `json:"address"` - Data string `json:"data"` + Data []byte `json:"data"` } diff --git a/plugins/webapi/findMessageById/plugin.go b/plugins/webapi/findMessageById/plugin.go new file mode 100644 index 0000000000000000000000000000000000000000..5c74ff33331a36b6b905c646138f0ec4f8e14fe7 --- /dev/null +++ b/plugins/webapi/findMessageById/plugin.go @@ -0,0 +1,85 @@ +package findMessageById + +import ( + "net/http" + + "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" + "github.com/iotaledger/goshimmer/plugins/messagelayer" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/labstack/echo" + + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" +) + +var PLUGIN = node.NewPlugin("WebAPI findMessageById Endpoint", node.Enabled, configure) +var log *logger.Logger + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-findMessageById") + webapi.Server.POST("findMessageById", findMessageById) +} + +// getMessageByHash returns the array of messages for the +// given message ids (MUST be encoded in base58), in the same order as the parameters. +// If a node doesn't have the message for a given ID in its ledger, +// the value at the index of that message ID is empty. +func findMessageById(c echo.Context) error { + var request Request + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return c.JSON(http.StatusBadRequest, Response{Error: err.Error()}) + } + + var result []Message + for _, id := range request.Ids { + log.Info("Received:", id) + + msgId, err := message.NewId(id) + if err != nil { + log.Info(err) + continue + } + + msgObject := messagelayer.Tangle.Message(msgId) + if !msgObject.Exists() { + continue + } + + msg := msgObject.Unwrap() + msgResp := Message{ + Id: msg.Id().String(), + TrunkId: msg.TrunkId().String(), + BranchId: msg.BranchId().String(), + IssuerPublicKey: msg.IssuerPublicKey().String(), + IssuingTime: msg.IssuingTime().String(), + SequenceNumber: msg.SequenceNumber(), + Payload: msg.Payload().Bytes(), + Signature: msg.Signature().String(), + } + result = append(result, msgResp) + msgObject.Release() + } + + return c.JSON(http.StatusOK, Response{Messages: result}) +} + +type Response struct { + Messages []Message `json:"messages,omitempty"` + Error string `json:"error,omitempty"` +} + +type Request struct { + Ids []string `json:"ids"` +} + +type Message struct { + Id string `json:"Id,omitempty"` + TrunkId string `json:"trunkId,omitempty"` + BranchId string `json:"branchId,omitempty"` + IssuerPublicKey string `json:"issuerPublicKey,omitempty"` + IssuingTime string `json:"issuingTime,omitempty"` + SequenceNumber uint64 `json:"sequenceNumber,omitempty"` + Payload []byte `json:"payload,omitempty"` + Signature string `json:"signature,omitempty"` +} diff --git a/plugins/webapi/findTransactionHashes/plugin.go b/plugins/webapi/findTransactionHashes/plugin.go deleted file mode 100644 index 29d573f148589cfafcb9b2c49ee26e083611d8e5..0000000000000000000000000000000000000000 --- a/plugins/webapi/findTransactionHashes/plugin.go +++ /dev/null @@ -1,58 +0,0 @@ -package findTransactionHashes - -import ( - "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" -) - -var PLUGIN = node.NewPlugin("WebAPI findTransactionHashes Endpoint", node.Enabled, configure) -var log *logger.Logger - -func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-findTransactionHashes") - webapi.Server.POST("findTransactionHashes", findTransactionHashes) -} - -// 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 findTransactionHashes(c echo.Context) error { - return c.JSON(http.StatusInternalServerError, Response{Error: "TODO: ADD LOGIC ACCORDING TO VALUE TANGLE"}) - - // TODO: ADD LOGIC ACCORDING TO VALUE TANGLE - /* - var request Request - - if err := c.Bind(&request); err != nil { - log.Info(err.Error()) - return c.JSON(http.StatusBadRequest, Response{Error: err.Error()}) - } - log.Debug("Received:", request.Addresses) - result := make([][]trinary.Trytes, len(request.Addresses)) - - for i, address := range request.Addresses { - txs, err := tangle_old.ReadTransactionHashesForAddressFromDatabase(address) - if err != nil { - return c.JSON(http.StatusInternalServerError, Response{Error: err.Error()}) - } - result[i] = append(result[i], txs...) - } - - return c.JSON(http.StatusOK, Response{Transactions: result}) - */ -} - -type Response struct { - Transactions [][]trinary.Trytes `json:"transactions,omitempty"` //string - Error string `json:"error,omitempty"` -} - -type Request struct { - Addresses []string `json:"addresses"` -} diff --git a/plugins/webapi/getTransactionObjectsByHash/plugin.go b/plugins/webapi/getTransactionObjectsByHash/plugin.go deleted file mode 100644 index 042ec46945f743b8d97e6b59e59a27e8f4ef8841..0000000000000000000000000000000000000000 --- a/plugins/webapi/getTransactionObjectsByHash/plugin.go +++ /dev/null @@ -1,87 +0,0 @@ -package getTransactionObjectsByHash - -import ( - "net/http" - - "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) -var log *logger.Logger - -func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-getTransactionObjectsByHash") - webapi.Server.POST("getTransactionObjectsByHash", getTransactionObjectsByHash) -} - -// 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 getTransactionObjectsByHash(c echo.Context) error { - - var request Request - result := []Transaction{} - - if err := c.Bind(&request); err != nil { - log.Info(err.Error()) - return c.JSON(http.StatusBadRequest, Response{Error: err.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()}) - } - 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}) -} - -type Response struct { - Transactions []Transaction `json:"transaction,omitempty"` - Error string `json:"error,omitempty"` -} - -type Request struct { - Hashes []string `json:"hashes"` -} - -type Transaction struct { - Hash trinary.Trytes `json:"hash,omitempty"` - WeightMagnitude int `json:"weightMagnitude,omitempty"` - TrunkTransactionHash trinary.Trytes `json:"trunkTransactionHash,omitempty"` - BranchTransactionHash trinary.Trytes `json:"branchTransactionHash,omitempty"` - Head bool `json:"head,omitempty"` - Tail bool `json:"tail,omitempty"` - Nonce trinary.Trytes `json:"nonce,omitempty"` - Address trinary.Trytes `json:"address,omitempty"` - Value int64 `json:"value,omitempty"` - Timestamp uint `json:"timestamp,omitempty"` - SignatureMessageFragment trinary.Trytes `json:"signatureMessageFragment,omitempty"` -} diff --git a/plugins/webapi/getTransactionTrytesByHash/plugin.go b/plugins/webapi/getTransactionTrytesByHash/plugin.go deleted file mode 100644 index bfa94613c2f2b01d5384d442df50968ae8b8e250..0000000000000000000000000000000000000000 --- a/plugins/webapi/getTransactionTrytesByHash/plugin.go +++ /dev/null @@ -1,60 +0,0 @@ -package getTransactionTrytesByHash - -import ( - "net/http" - - "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) -var log *logger.Logger - -func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-getTransactionTrytesByHash") - webapi.Server.POST("getTransactionTrytesByHash", getTransactionTrytesByHash) -} - -// 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 getTransactionTrytesByHash(c echo.Context) error { - - var request Request - result := []trinary.Trytes{} - if err := c.Bind(&request); err != nil { - log.Info(err.Error()) - return c.JSON(http.StatusBadRequest, Response{Error: err.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()}) - } - 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}) -} - -type Response struct { - Trytes []trinary.Trytes `json:"trytes,omitempty"` //string - Error string `json:"error,omitempty"` -} - -type Request struct { - Hashes []string `json:"hashes"` -} diff --git a/tools/relay-checker/config.go b/tools/relay-checker/config.go index d7c2b2101a9a18c099f29a95f254ef5e5e45ad43..fc9f2c6159df6d22c02762fcdfb4e4e044f35a6b 100644 --- a/tools/relay-checker/config.go +++ b/tools/relay-checker/config.go @@ -5,8 +5,7 @@ import "github.com/iotaledger/goshimmer/plugins/config" var ( nodes []string target = "" - txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999" - txnData = "TEST99BROADCAST99DATA" + msgData = "TEST99BROADCAST99DATA" cooldownTime = 2 repeat = 1 ) @@ -23,11 +22,8 @@ func InitConfig() { nodes = append(nodes, config.Node.GetStringSlice(CFG_TEST_NODES)...) // optional settings - if config.Node.GetString(CFG_TX_ADDRESS) != "" { - txnAddr = config.Node.GetString(CFG_TX_ADDRESS) - } if config.Node.GetString(CFG_DATA) != "" { - txnData = config.Node.GetString(CFG_DATA) + msgData = config.Node.GetString(CFG_DATA) } if config.Node.GetInt(CFG_COOLDOWN_TIME) > 0 { cooldownTime = config.Node.GetInt(CFG_COOLDOWN_TIME) diff --git a/tools/relay-checker/config.json b/tools/relay-checker/config.json index a830da125c7c13353b020933dc0a7a9a884cfc86..27a1dee20a7c4300a37878c889d1e7a1ae4e88a8 100644 --- a/tools/relay-checker/config.json +++ b/tools/relay-checker/config.json @@ -4,7 +4,6 @@ "testNodes": [ "http://127.0.0.1:8080" ], - "txAddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "data": "TEST99BROADCAST99DATA", "cooldownTime": 10, "repeat": 2 diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 8e98efcab1c082a4226dab42bef9c857f9370ab4..df7e812626a6cce48707ed455feca16d36e009a7 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -7,34 +7,32 @@ import ( client "github.com/iotaledger/goshimmer/client" "github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/logger" - - "github.com/iotaledger/iota.go/trinary" ) -func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { - txnHash, err := api.BroadcastData(txnAddr, txnData) +func testBroadcastData(api *client.GoShimmerAPI) (string, error) { + msgId, err := api.BroadcastData([]byte(msgData)) if err != nil { return "", fmt.Errorf("broadcast failed: %w", err) } - return txnHash, nil + return msgId, nil } -func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error { +func testTargetGetMessagess(api *client.GoShimmerAPI, msgId string) error { // query target node for broadcasted data - if _, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash}); err != nil { + if _, err := api.FindMessageById([]string{msgId}); err != nil { return fmt.Errorf("querying the target node failed: %w", err) } return nil } -func testNodesGetTransactions(txnHash trinary.Hash) error { +func testNodesGetMessages(msgId string) error { // query nodes node for broadcasted data for _, n := range nodes { nodesApi := client.NewGoShimmerAPI(n) - if _, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash}); err != nil { + if _, err := nodesApi.FindMessageById([]string{msgId}); err != nil { return fmt.Errorf("querying node %s failed: %w", n, err) } - fmt.Printf("txn found in node %s\n", n) + fmt.Printf("msg found in node %s\n", n) } return nil } @@ -47,25 +45,25 @@ func main() { api := client.NewGoShimmerAPI(target) for i := 0; i < repeat; i++ { - txnHash, err := testBroadcastData(api) + msgId, err := testBroadcastData(api) if err != nil { fmt.Printf("%s\n", err) break } - fmt.Printf("txnHash: %s\n", txnHash) + fmt.Printf("msgId: %s\n", msgId) // cooldown time time.Sleep(time.Duration(cooldownTime) * time.Second) // query target node - err = testTargetGetTransactions(api, txnHash) + err = testTargetGetMessagess(api, msgId) if err != nil { fmt.Printf("%s\n", err) break } // query test nodes - err = testNodesGetTransactions(txnHash) + err = testNodesGetMessages(msgId) if err != nil { fmt.Printf("%s\n", err) break diff --git a/tools/relay-checker/parameters.go b/tools/relay-checker/parameters.go index ac64aaf77069fc73aa26bf65116c61cca23eee91..9c6a83456f84daa076c769faaa8447f57081efb5 100644 --- a/tools/relay-checker/parameters.go +++ b/tools/relay-checker/parameters.go @@ -7,7 +7,6 @@ import ( const ( CFG_TARGET_NODE = "relayChecker.targetNode" CFG_TEST_NODES = "relayChecker.testNodes" - CFG_TX_ADDRESS = "relayChecker.txAddress" CFG_DATA = "relayChecker.data" CFG_COOLDOWN_TIME = "relayChecker.cooldownTime" CFG_REPEAT = "relayChecker.repeat" @@ -15,8 +14,7 @@ const ( func init() { flag.StringSlice(CFG_TEST_NODES, []string{""}, "the list of nodes to check after the cooldown") - flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "the target node from the which transaction will be broadcasted from") - flag.String(CFG_TX_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "the transaction address") + flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "the target node from the which message will be broadcasted from") flag.String(CFG_DATA, "TEST99BROADCAST99DATA", "data to broadcast") flag.Int(CFG_COOLDOWN_TIME, 10, "the cooldown time after broadcasting the data on the specified target node") flag.Int(CFG_REPEAT, 1, "the amount of times to repeat the relay-checker queries")