Skip to content

Commit

Permalink
Merge pull request #111 from iotaledger/chore/update-inx-app-and-iotago
Browse files Browse the repository at this point in the history
Update modules
  • Loading branch information
muXxer authored Dec 1, 2023
2 parents 15eb71e + ec4c81d commit 16ace65
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 75 deletions.
2 changes: 1 addition & 1 deletion components/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
Name = "inx-faucet"

// Version of the app.
Version = "2.0.0-alpha.13"
Version = "2.0.0-alpha.14"
)

func App() *app.App {
Expand Down
9 changes: 3 additions & 6 deletions components/faucet/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func provide(c *dig.Container) error {

if err := c.Provide(func(deps faucetDeps) (*faucet.Faucet, error) {

fetchTransactionMetadata := func(blockID iotago.BlockID) (*faucet.TransactionMetadata, error) {
fetchTransactionMetadata := func(transactionID iotago.TransactionID) (*api.TransactionMetadataResponse, error) {
ctx, cancel := context.WithTimeout(Component.Daemon().ContextStopped(), 5*time.Second)
defer cancel()

metadata, err := deps.NodeBridge.BlockMetadata(ctx, blockID)
metadata, err := deps.NodeBridge.TransactionMetadata(ctx, transactionID)
if err != nil {
st, ok := status.FromError(err)
if ok && st.Code() == codes.NotFound {
Expand All @@ -114,10 +114,7 @@ func provide(c *dig.Container) error {
return nil, err
}

return &faucet.TransactionMetadata{
State: metadata.GetTransactionState(),
FailureReason: metadata.GetTransactionFailureReason(),
}, nil
return metadata, nil
}

Component.LogInfo("Initializing indexer...")
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ require (
github.com/iotaledger/hive.go/lo v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42
github.com/iotaledger/hive.go/runtime v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231128163614-c82e1fa40733
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231128162307-cc6b309e93ef
github.com/iotaledger/iota.go/v4 v4.0.0-20231128162016-23f1b4e12cec
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221
github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22
github.com/labstack/echo/v4 v4.11.3
go.uber.org/dig v1.17.1
golang.org/x/time v0.4.0
Expand Down Expand Up @@ -46,6 +45,7 @@ require (
github.com/iotaledger/hive.go/constraints v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6c
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8=
github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe h1:RcFUqhnJ+86+sA0XMrZ0q+086ULrdWQkWrjUt2OnJK4=
github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231128163614-c82e1fa40733 h1:jdjFTuMum+fctCq+UdEGk0pRi+JLqLm3cDMC9kUEPAs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231128163614-c82e1fa40733/go.mod h1:3ae5TFi3uaECV+F4d5ekKz+xcJQmVtCICcs/Rhvgn3w=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231128162307-cc6b309e93ef h1:RImO23W0kL3U9egdLoi5OTmOIhE5rHfR/dKM/6XhZeE=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231128162307-cc6b309e93ef/go.mod h1:bi0zndM3irf8FHYUg6MzG/Zk/t0fV8IwGXAdoT7wn98=
github.com/iotaledger/iota.go/v4 v4.0.0-20231128162016-23f1b4e12cec h1:u9SAuKHygJwqwYxoEd+PyHCU4fTftcPdV2ZUGSRZe8o=
github.com/iotaledger/iota.go/v4 v4.0.0-20231128162016-23f1b4e12cec/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 h1:+ozrau44uPy2kYv2fuj2Wks8+VkXR62WB9zONOJgzdE=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0=
github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 h1:awGSiqmM1pYF+e+uILNQAiiNXrirU/mTYmUf4f/wVac=
github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
Expand Down
28 changes: 11 additions & 17 deletions pkg/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/iotaledger/hive.go/runtime/syncutils"
"github.com/iotaledger/hive.go/runtime/timeutil"
"github.com/iotaledger/inx-app/pkg/httpserver"
inx "github.com/iotaledger/inx/go"
iotago "github.com/iotaledger/iota.go/v4"
"github.com/iotaledger/iota.go/v4/api"
"github.com/iotaledger/iota.go/v4/builder"
)

Expand All @@ -42,18 +42,12 @@ var (
}
)

// TransactionMetadata contains the transaction metadata required by the faucet.
type TransactionMetadata struct {
State inx.BlockMetadata_TransactionState
FailureReason inx.BlockMetadata_TransactionFailureReason
}

type (
// IsNodeHealthyFunc is a function to query if the used node is synced.
IsNodeHealthyFunc func() bool
// FetchTransactionMetadataFunc is a function to fetch the required metadata of a transaction contained in a block for a given block ID.
// This returns nil if the block is not found.
FetchTransactionMetadataFunc func(blockID iotago.BlockID) (*TransactionMetadata, error)
// FetchTransactionMetadataFunc is a function to fetch the required metadata of a transaction.
// This returns nil if the transaction is not found.
FetchTransactionMetadataFunc func(transactionID iotago.TransactionID) (*api.TransactionMetadataResponse, error)
// CollectUnlockableFaucetOutputsFunc is a function to collect the unlockable outputs of the faucet.
CollectUnlockableFaucetOutputsFunc func() ([]UTXOBasicOutput, error)
// CollectUnlockableFaucetOutputsAndBalanceFunc is a function to collect the unlockable outputs and the balance of the faucet.
Expand Down Expand Up @@ -904,7 +898,7 @@ func (f *Faucet) checkPendingTransactionState() {
return
}

metadata, err := f.fetchTransactionMetadataFunc(pendingTx.BlockID)
metadata, err := f.fetchTransactionMetadataFunc(pendingTx.TransactionID)
if err != nil {
// an error occurred => re-add the items to the queue and delete the pending transaction
f.logSoftError(ierrors.Errorf("failed to fetch metadata of the pending transaction, blockID: %s, txID: %s", pendingTx.BlockID, pendingTx.TransactionID))
Expand All @@ -922,27 +916,27 @@ func (f *Faucet) checkPendingTransactionState() {
return
}

switch metadata.State {
case inx.BlockMetadata_TRANSACTION_STATE_NO_TRANSACTION:
switch metadata.TransactionState {
case api.TransactionStateNoTransaction:
// transaction is not known, so the block must have been filtered
// => re-add the items to the queue and delete the pending transaction
f.logSoftError(ierrors.Errorf("metadata of the pending transaction is no transaction, blockID: %s, txID: %s", pendingTx.BlockID, pendingTx.TransactionID))
f.readdPendingRequestsWithoutLocking()

case inx.BlockMetadata_TRANSACTION_STATE_PENDING:
case api.TransactionStatePending:
// transaction is still pending
f.LogDebugf("checkPendingTransactionState: transaction still pending, blockID: %s, txID: %s", pendingTx.BlockID, pendingTx.TransactionID)

case inx.BlockMetadata_TRANSACTION_STATE_ACCEPTED, inx.BlockMetadata_TRANSACTION_STATE_CONFIRMED, inx.BlockMetadata_TRANSACTION_STATE_FINALIZED:
case api.TransactionStateAccepted, api.TransactionStateConfirmed, api.TransactionStateFinalized:
// transaction was confirmed
// => delete the requests and the pending transaction
f.LogDebugf("checkPendingTransactionState: transaction successful, blockID: %s, txID: %s", pendingTx.BlockID, pendingTx.TransactionID)
f.clearPendingRequestsWithoutLocking()

case inx.BlockMetadata_TRANSACTION_STATE_FAILED:
case api.TransactionStateFailed:
// transaction failed
// => re-add the items to the queue and delete the pending transaction
f.logSoftError(ierrors.Errorf("transaction failed, blockID: %s, txID: %s, reason: %d", pendingTx.BlockID, pendingTx.TransactionID, metadata.FailureReason))
f.logSoftError(ierrors.Errorf("transaction failed, blockID: %s, txID: %s, reason: %d", pendingTx.BlockID, pendingTx.TransactionID, metadata.TransactionFailureReason))
f.readdPendingRequestsWithoutLocking()
}
}
Expand Down
28 changes: 14 additions & 14 deletions tools/gendoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/crypto v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/ierrors v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/lo v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/hive.go/runtime v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 // indirect
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231127162144-bba7e494e442 // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231124154447-f20fb8921e8c // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe // indirect
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo/v4 v4.11.3 // indirect
Expand Down Expand Up @@ -75,13 +75,13 @@ require (
go.uber.org/dig v1.17.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 16ace65

Please sign in to comment.