Skip to content

Commit

Permalink
Fix below max depth bug (#18)
Browse files Browse the repository at this point in the history
* Check if node is synced before submitting a block

* Do not clear the pending requests if a block is unknown

* Use OutputID instead if string as map keys

* Check if the lastBlockID is below max depth

* Adapt tests to latest hornet version

* Release v0.9.1
  • Loading branch information
muXxer authored Jul 11, 2022
1 parent 373b56a commit 536d899
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 136 deletions.
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 = "0.9.0"
Version = "0.9.1"
)

func App() *app.App {
Expand Down
10 changes: 9 additions & 1 deletion core/faucet/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ func provide(c *dig.Container) error {
return faucetOutputs, nil
}

submitBlock := func(ctx context.Context, block *iotago.Block) (iotago.BlockID, error) {
if !deps.NodeBridge.IsNodeAlmostSynced() {
return iotago.BlockID{}, errors.New("node is not synced")
}

return deps.NodeBridge.SubmitBlock(ctx, block)
}

return faucet.New(
CoreComponent.Daemon(),
fetchMetadata,
Expand All @@ -155,7 +163,7 @@ func provide(c *dig.Container) error {
protoParas,
&faucetAddress,
faucetSigner,
deps.NodeBridge.SubmitBlock,
submitBlock,
faucet.WithLogger(CoreComponent.Logger()),
faucet.WithTokenName(deps.NodeBridge.NodeConfig.BaseToken.Name),
faucet.WithAmount(ParamsFaucet.Amount),
Expand Down
46 changes: 21 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/iotaledger/inx-faucet
go 1.18

require (
github.com/iotaledger/hive.go v0.0.0-20220531132324-8347a155e220
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-20220531132324-8347a155e220
github.com/iotaledger/hornet v1.1.0-rc1.0.20220621111400-f5426c2ac1ae
github.com/iotaledger/inx-app v0.0.0-20220621112154-a10fe25839ed
github.com/iotaledger/inx/go v0.0.0-20220615123503-f64096762c65
github.com/iotaledger/iota.go/v3 v3.0.0-20220621104034-d2f8a5e6287e
github.com/iotaledger/hive.go v0.0.0-20220707144500-ae0ecb7af9bf
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-20220707144500-ae0ecb7af9bf
github.com/iotaledger/hornet v1.1.0-rc1.0.20220711110438-e716d1c534c0
github.com/iotaledger/inx-app v0.0.0-20220705125128-ee367df6181f
github.com/iotaledger/inx/go v0.0.0-20220705124918-775bb201b49e
github.com/iotaledger/iota.go/v3 v3.0.0-20220705124454-acc836567dfb
github.com/labstack/echo/v4 v4.7.2
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.4
github.com/stretchr/testify v1.8.0
go.uber.org/dig v1.14.1
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
google.golang.org/grpc v1.47.0
Expand All @@ -22,21 +22,19 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.23.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
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-20220616214320-059c072fd94a // indirect
github.com/cockroachdb/pebble v0.0.0-20220708173837-d3484a60444e // 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.19 // indirect
github.com/ethereum/go-ethereum v1.10.20 // 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 @@ -51,41 +49,39 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-version v1.5.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/iotaledger/go-ds-kvstore v0.0.0-20220404122649-445475b91fcf // indirect
github.com/iotaledger/iota.go v1.0.0 // indirect
github.com/ipfs/go-cid v0.2.0 // indirect
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.6 // indirect
github.com/klauspost/compress v1.15.7 // indirect
github.com/klauspost/cpuid/v2 v2.0.14 // indirect
github.com/knadh/koanf v1.4.2 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.3.2-0.20220410183028-64116baad496 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/libp2p/go-libp2p-core v0.17.0 // indirect
github.com/libp2p/go-libp2p-peerstore v0.7.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-libp2p-core v0.19.1 // indirect
github.com/libp2p/go-libp2p-peerstore v0.7.1 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.0.4 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr v0.5.0 // indirect
github.com/multiformats/go-multiaddr v0.6.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.5.0 // indirect
github.com/multiformats/go-multihash v0.1.0 // indirect
github.com/multiformats/go-multihash v0.2.0 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/panjf2000/ants/v2 v2.5.0 // indirect
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c // indirect
Expand All @@ -111,14 +107,14 @@ require (
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/exp v0.0.0-20220706164943-b4a6d9510983 // indirect
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // 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-20220617124728-180714bec0ad // indirect
google.golang.org/genproto v0.0.0-20220708155623-50e5f4832e73 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 536d899

Please sign in to comment.