Skip to content

Commit

Permalink
- Using inx batch (#29)
Browse files Browse the repository at this point in the history
- Updated deps
- Added debug request logging
  • Loading branch information
alexsporn authored Aug 4, 2022
1 parent cb4d1bd commit 4ab1827
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 109 deletions.
3 changes: 2 additions & 1 deletion config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"period": "5m",
"maxRequests": 10,
"maxBurst": 20
}
},
"debugRequestLoggerEnabled": false
},
"profiling": {
"enabled": false,
Expand Down
2 changes: 1 addition & 1 deletion core/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 = "1.0.0-beta.3"
Version = "1.0.0-beta.4"
)

func App() *app.App {
Expand Down
2 changes: 2 additions & 0 deletions core/faucet/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type ParametersFaucet struct {
MaxRequests int `default:"10" usage:"the maximum number of requests per period"`
MaxBurst int `default:"20" usage:"additional requests allowed in the burst period"`
}
// DebugRequestLoggerEnabled defines whether the debug logging for requests should be enabled
DebugRequestLoggerEnabled bool `default:"false" usage:"whether the debug logging for requests should be enabled"`
}

var ParamsFaucet = &ParametersFaucet{
Expand Down
12 changes: 5 additions & 7 deletions core/faucet/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"strings"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"go.uber.org/dig"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/iotaledger/hive.go/app/core/shutdown"
"github.com/iotaledger/hive.go/crypto"
"github.com/iotaledger/hornet/v2/pkg/common"
"github.com/iotaledger/inx-app/httpserver"
"github.com/iotaledger/inx-app/nodebridge"
"github.com/iotaledger/inx-faucet/pkg/daemon"
"github.com/iotaledger/inx-faucet/pkg/faucet"
Expand Down Expand Up @@ -186,13 +186,13 @@ func run() error {

// create a background worker that handles the ledger updates
CoreComponent.Daemon().BackgroundWorker("Faucet[LedgerUpdates]", func(ctx context.Context) {
if err := deps.NodeBridge.ListenToLedgerUpdates(ctx, 0, 0, func(update *inx.LedgerUpdate) error {
if err := deps.NodeBridge.ListenToLedgerUpdates(ctx, 0, 0, func(update *nodebridge.LedgerUpdate) error {
createdOutputs := iotago.OutputIDs{}
for _, output := range update.GetCreated() {
for _, output := range update.Created {
createdOutputs = append(createdOutputs, output.GetOutputId().Unwrap())
}
consumedOutputs := iotago.OutputIDs{}
for _, spent := range update.GetConsumed() {
for _, spent := range update.Consumed {
consumedOutputs = append(consumedOutputs, spent.GetOutput().GetOutputId().Unwrap())
}

Expand All @@ -215,9 +215,7 @@ func run() error {
CoreComponent.LogPanicf("failed to start worker: %s", err)
}

e := echo.New()
e.HideBanner = true
e.Use(middleware.Recover())
e := httpserver.NewEcho(CoreComponent.Logger(), nil, ParamsFaucet.DebugRequestLoggerEnabled)
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPost},
Expand Down
24 changes: 13 additions & 11 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ Example:

## <a id="faucet"></a> 3. Faucet

| Name | Description | Type | Default value |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------ | ---------------- |
| amount | The amount of funds the requester receives | uint | 1000000000 |
| smallAmount | The amount of funds the requester receives if the target address has more funds than the faucet amount and less than maximum | uint | 100000000 |
| maxAddressBalance | The maximum allowed amount of funds on the target address | uint | 2000000000 |
| maxOutputCount | The maximum output count per faucet message | int | 128 |
| tagMessage | The faucet transaction tag payload | string | "HORNET FAUCET" |
| batchTimeout | The maximum duration for collecting faucet batches | string | "2s" |
| bindAddress | The bind address on which the faucet website can be accessed from | string | "localhost:8091" |
| [rateLimit](#faucet_ratelimit) | Configuration for rateLimit | object | |
| Name | Description | Type | Default value |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------- |
| amount | The amount of funds the requester receives | uint | 1000000000 |
| smallAmount | The amount of funds the requester receives if the target address has more funds than the faucet amount and less than maximum | uint | 100000000 |
| maxAddressBalance | The maximum allowed amount of funds on the target address | uint | 2000000000 |
| maxOutputCount | The maximum output count per faucet message | int | 128 |
| tagMessage | The faucet transaction tag payload | string | "HORNET FAUCET" |
| batchTimeout | The maximum duration for collecting faucet batches | string | "2s" |
| bindAddress | The bind address on which the faucet website can be accessed from | string | "localhost:8091" |
| [rateLimit](#faucet_ratelimit) | Configuration for rateLimit | object | |
| debugRequestLoggerEnabled | Whether the debug logging for requests should be enabled | boolean | false |

### <a id="faucet_ratelimit"></a> RateLimit

Expand All @@ -99,7 +100,8 @@ Example:
"period": "5m",
"maxRequests": 10,
"maxBurst": 20
}
},
"debugRequestLoggerEnabled": false
}
}
```
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.18
require (
github.com/iotaledger/hive.go v0.0.0-20220714075325-11202fe498d6
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-20220714075325-11202fe498d6
github.com/iotaledger/hornet/v2 v2.0.0-beta.1.0.20220721081848-6838d5b9273b
github.com/iotaledger/inx-app v1.0.0-beta.3
github.com/iotaledger/inx/go v1.0.0-beta.3
github.com/iotaledger/hornet/v2 v2.0.0-beta.3
github.com/iotaledger/inx-app v1.0.0-beta.6
github.com/iotaledger/inx/go v1.0.0-beta.4
github.com/iotaledger/iota.go/v3 v3.0.0-beta.4
github.com/labstack/echo/v4 v4.7.2
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
go.uber.org/dig v1.14.1
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
go.uber.org/dig v1.15.0
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
google.golang.org/grpc v1.48.0
)

Expand All @@ -27,14 +27,14 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cockroachdb/errors v1.9.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/pebble v0.0.0-20220719144226-63d552794411 // indirect
github.com/cockroachdb/pebble v0.0.0-20220726134658-7b78c71e4055 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/ethereum/go-ethereum v1.10.20 // indirect
github.com/ethereum/go-ethereum v1.10.21 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/getsentry/sentry-go v0.13.0 // indirect
Expand All @@ -57,7 +57,7 @@ require (
github.com/ipfs/go-datastore v0.5.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/compress v1.15.8 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/knadh/koanf v1.4.2 // indirect
github.com/kr/pretty v0.3.0 // indirect
Expand Down Expand Up @@ -92,7 +92,7 @@ require (
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
Expand All @@ -108,14 +108,14 @@ require (
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75 // indirect
golang.org/x/net v0.0.0-20220725212005-46097bf591d3 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/genproto v0.0.0-20220803205849-8f55acc8769f // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
Expand Down
Loading

0 comments on commit 4ab1827

Please sign in to comment.