Skip to content

Commit

Permalink
#5412: review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Sep 26, 2024
1 parent adeaaf0 commit 4876f2e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ingest/cdp/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/stellar/go/ingest/ledgerbackend"
"github.com/stellar/go/support/datastore"
"github.com/stellar/go/support/errors"
"github.com/stellar/go/support/log"
"github.com/stellar/go/support/ordered"
"github.com/stellar/go/xdr"
Expand Down Expand Up @@ -102,6 +101,7 @@ func PublishFromBufferedStorageBackend(ledgerRange ledgerbackend.Range,
resultCh := make(chan error, 1)

go func() {
defer close(resultCh)
dataStore, err := datastoreFactory(ctx, publisherConfig.DataStoreConfig)
if err != nil {
resultCh <- fmt.Errorf("failed to create datastore: %w", err)
Expand All @@ -120,12 +120,12 @@ func PublishFromBufferedStorageBackend(ledgerRange ledgerbackend.Range,
}

if ledgerRange.Bounded() && ledgerRange.To() <= ledgerRange.From() {
resultCh <- errors.New("invalid end value for bounded range, must be greater than start")
resultCh <- fmt.Errorf("invalid end value for bounded range, must be greater than start")
return
}

if !ledgerRange.Bounded() && ledgerRange.To() > 0 {
resultCh <- errors.New("invalid end value for unbounded ranged, must be zero")
resultCh <- fmt.Errorf("invalid end value for unbounded range, must be zero")
return
}

Expand All @@ -145,7 +145,7 @@ func PublishFromBufferedStorageBackend(ledgerRange ledgerbackend.Range,
ledgerCloseMeta, err = ledgerBackend.GetLedger(ctx, ledgerSeq)

if err != nil {
resultCh <- errors.Wrap(err, "error getting ledger")
resultCh <- fmt.Errorf("error getting ledger, %w", err)
return
}

Expand All @@ -156,11 +156,10 @@ func PublishFromBufferedStorageBackend(ledgerRange ledgerbackend.Range,

err = callback(ledgerCloseMeta)
if err != nil {
resultCh <- errors.Wrap(err, "received an error from callback invocation")
resultCh <- fmt.Errorf("received an error from callback invocation: %w", err)
return
}
}
close(resultCh)
}()

return resultCh
Expand Down

0 comments on commit 4876f2e

Please sign in to comment.