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

Fix tx fetch #94

Merged
merged 2 commits into from
Mar 4, 2024
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
38 changes: 11 additions & 27 deletions multiepoch-getTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (multi *MultiEpoch) findEpochNumberFromSignature(ctx context.Context, sig s
return epochs[0], nil
}

// Linear search:
numbers := multi.GetEpochNumbers()
// sort from highest to lowest:
sort.Slice(numbers, func(i, j int) bool {
Expand All @@ -48,37 +47,22 @@ func (multi *MultiEpoch) findEpochNumberFromSignature(ctx context.Context, sig s

buckets := multi.getAllBucketteers()

found := make([]uint64, 0)
startedSearchingCandidatesAt := time.Now()
for _, epochNumber := range numbers {
bucket, ok := buckets[epochNumber]
if !ok {
continue
}
if has, err := bucket.Has(sig); err != nil {
return 0, fmt.Errorf("failed to check if signature exists in bucket: %w", err)
} else if has {
found = append(found, epochNumber)
}
}
klog.V(4).Infof(
"Searched %d epochs in %s, and found %d candidate epochs for signature %s: %v",
len(numbers),
time.Since(startedSearchingCandidatesAt),
len(found),
sig,
found,
)

if len(found) == 0 {
return 0, ErrNotFound
}

// Search all epochs in parallel:
wg := NewFirstResponse(ctx, multi.options.EpochSearchConcurrency)
for i := range numbers {
epochNumber := numbers[i]
wg.Spawn(func() (any, error) {
bucket, ok := buckets[epochNumber]
if !ok {
return nil, nil
}
has, err := bucket.Has(sig)
if err != nil {
return 0, fmt.Errorf("failed to check if signature exists in bucket: %w", err)
}
if !has {
return nil, nil
}
epoch, err := multi.GetEpoch(epochNumber)
if err != nil {
return nil, fmt.Errorf("failed to get epoch %d: %w", epochNumber, err)
Expand Down
3 changes: 1 addition & 2 deletions split-car-fetcher/remote-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"net/http"
"path/filepath"
"time"

"github.com/goware/urlx"
Expand Down Expand Up @@ -35,7 +34,7 @@ func NewRemoteHTTPFileAsIoReaderAt(ctx context.Context, url string) (ReaderAtClo
if err != nil {
return nil, 0, err
}
name := filepath.Base(parsedURL.Path)
name := parsedURL.Path

rc := rangecache.NewRangeCache(
contentLength,
Expand Down
Loading