Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iota-imt
goshimmer
Commits
54866b13
Commit
54866b13
authored
5 years ago
by
Hans Moog
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: uncommented broken code
parent
49b59250
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/webapi/getTransactionObjectsByHash/plugin.go
+26
-25
26 additions, 25 deletions
plugins/webapi/getTransactionObjectsByHash/plugin.go
plugins/webapi/getTransactionTrytesByHash/plugin.go
+14
-12
14 additions, 12 deletions
plugins/webapi/getTransactionTrytesByHash/plugin.go
with
40 additions
and
37 deletions
plugins/webapi/getTransactionObjectsByHash/plugin.go
+
26
−
25
View file @
54866b13
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
})
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/getTransactionTrytesByHash/plugin.go
+
14
−
12
View file @
54866b13
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
})
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment