Skip to content

Commit

Permalink
Merge branch 'main' into hlib/share/namespace-integration-new
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Jun 27, 2023
2 parents 3adde19 + 0267e21 commit a793715
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
19 changes: 9 additions & 10 deletions libs/utils/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ func ValidateAddr(addr string) (string, error) {
return addr, err
}

if ip := net.ParseIP(addr); ip == nil {
addrs, err := net.LookupHost(addr)
if err != nil {
return addr, fmt.Errorf("could not resolve %v: %w", addr, err)
}
if len(addrs) == 0 {
return addr, fmt.Errorf("no IP addresses found for DNS record: %v", addr)
}
addr = addrs[0]
ip := net.ParseIP(addr)
if ip != nil {
return addr, nil
}
return addr, nil

resolved, err := net.ResolveIPAddr("ip4", addr)
if err != nil {
return addr, err
}
return resolved.String(), nil
}
16 changes: 16 additions & 0 deletions share/getters/shrex.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
"go.opentelemetry.io/otel/metric/instrument"
"go.opentelemetry.io/otel/metric/instrument/syncint64"
"go.opentelemetry.io/otel/metric/unit"
"go.opentelemetry.io/otel/trace"

"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-node/libs/utils"
"github.com/celestiaorg/celestia-node/share"
"github.com/celestiaorg/celestia-node/share/p2p"
"github.com/celestiaorg/celestia-node/share/p2p/peers"
Expand Down Expand Up @@ -126,6 +128,13 @@ func (sg *ShrexGetter) GetEDS(ctx context.Context, root *share.Root) (*rsmt2d.Ex
attempt int
err error
)
ctx, span := tracer.Start(ctx, "shrex/get-eds", trace.WithAttributes(
attribute.String("root", root.String()),
))
defer func() {
utils.SetStatusAndEnd(span, err)
}()

for {
if ctx.Err() != nil {
sg.metrics.recordEDSAttempt(ctx, attempt, false)
Expand Down Expand Up @@ -188,6 +197,13 @@ func (sg *ShrexGetter) GetSharesByNamespace(
attempt int
err error
)
ctx, span := tracer.Start(ctx, "shrex/get-shares-by-namespace", trace.WithAttributes(
attribute.String("root", root.String()),
attribute.String("nid", hex.EncodeToString(id)),

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Run Integration Tests

undefined: hex

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Run Integration Tests

undefined: id

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Unit Tests Coverage

undefined: hex

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Unit Tests Coverage

undefined: id

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Unit Tests Coverage

undefined: hex

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Unit Tests Coverage

undefined: id

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Run Unit Tests with Race Detector

undefined: hex

Check failure on line 202 in share/getters/shrex.go

View workflow job for this annotation

GitHub Actions / go-ci / Run Unit Tests with Race Detector

undefined: id
))
defer func() {
utils.SetStatusAndEnd(span, err)
}()

// verify that the namespace could exist inside the roots before starting network requests
roots := filterRootsByNamespace(root, namespace)
Expand Down

0 comments on commit a793715

Please sign in to comment.