Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap faucet errors and add faucet logging #2411

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/faucet/connector.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package faucet

import (
"fmt"

"github.com/iotaledger/hive.go/core/types/confirmation"
"github.com/pkg/errors"

Expand Down Expand Up @@ -31,8 +33,10 @@ func (f *FaucetConnector) UnspentOutputs(addresses ...address.Address) (unspentO
unspentOutputs = make(map[address.Address]map[utxo.OutputID]*wallet.Output)

for _, addr := range addresses {
fmt.Println("> Getting unspent outputs for ", addr.Base58())
f.indexer.CachedAddressOutputMappings(addr.Address()).Consume(func(mapping *indexer.AddressOutputMapping) {
f.tangle.Ledger.Storage.CachedOutput(mapping.OutputID()).Consume(func(output utxo.Output) {
fmt.Println("> > Found output ", output.String())
if typedOutput, ok := output.(devnetvm.Output); ok {
f.tangle.Ledger.Storage.CachedOutputMetadata(typedOutput.ID()).Consume(func(outputMetadata *ledger.OutputMetadata) {
if !outputMetadata.IsSpent() {
Expand All @@ -57,7 +61,7 @@ func (f *FaucetConnector) UnspentOutputs(addresses ...address.Address) (unspentO
})
})
}

fmt.Printf("%+v\n", unspentOutputs)
return
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/cockroachdb/errors"
"github.com/iotaledger/hive.go/core/bitmask"
"github.com/iotaledger/hive.go/core/identity"

Expand Down Expand Up @@ -66,7 +67,7 @@ func (f *Faucet) handleFaucetRequest(p *faucet.Payload, ctx context.Context) (*d
sendoptions.Context(ctx),
)
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "failed to send first transaction from %s to %s", f.Seed().Address(0).Base58(), f.Seed().Address(1).Base58())
}

// send funds to requester
Expand All @@ -78,5 +79,5 @@ func (f *Faucet) handleFaucetRequest(p *faucet.Payload, ctx context.Context) (*d
sendoptions.WaitForConfirmation(true),
sendoptions.Context(ctx),
)
return tx, err
return tx, errors.Wrapf(err, "failed to send second transaction from %s to %s", f.Seed().Address(1).Base58(), p.Address().Base58())
}