Skip to content

Commit

Permalink
refactor(nodes): add more error information for the `EnsureTransactio…
Browse files Browse the repository at this point in the history
…nInEveryMempool` method
  • Loading branch information
adrianbrad committed Nov 1, 2023
1 parent 53d09ad commit 57783e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/gdamore/tcell/v2 v2.6.0
github.com/matryer/is v1.4.1
github.com/ory/dockertest/v3 v3.10.0
github.com/rivo/tview v0.0.0-20231024211518-8b7bcf9883df
github.com/rivo/tview v0.0.0-20231031172508-2dfe06011790
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.26.0
Expand Down Expand Up @@ -63,12 +63,12 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.9 // indirect
github.com/opencontainers/runc v1.1.10 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/shirou/gopsutil/v3 v3.23.9 // indirect
github.com/shirou/gopsutil/v3 v3.23.10 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -85,7 +85,7 @@ require (
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // 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
8 changes: 8 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package privatebtc

import (
"context"
"errors"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -211,9 +212,33 @@ func (nodes Nodes) EnsureTransactionInEveryMempool(
}

if !ok {
var errs error

rawMempool, err := node.RPCClient().GetRawMempool(ctx)
if err != nil {
errs = errors.Join(errs, fmt.Errorf("get raw mempool: %w", err))
}

connCount, err := node.RPCClient().GetConnectionCount(ctx)
if err != nil {
errs = errors.Join(errs, fmt.Errorf("get connection count: %w", err))
}

tx, err := node.RPCClient().GetTransaction(ctx, txHash)
if err != nil {
errs = errors.Join(errs, fmt.Errorf("get raw transaction: %w", err))

Check failure on line 229 in node.go

View workflow job for this annotation

GitHub Actions / lint

ineffectual assignment to errs (ineffassign)
}

return fmt.Errorf(
"get tx for node %d: %w",
"get tx %q for node %d, "+
"raw mempool: %q, "+
"connection count: %d, "+
"raw tx %+v: %w",
txHash,
i,
rawMempool,
connCount,
tx,
ErrTxNotFoundInMempool,
)
}
Expand Down

0 comments on commit 57783e0

Please sign in to comment.