Skip to content

Commit

Permalink
exp/lighthorizon: Minor error-handling and deployment improvements. (#…
Browse files Browse the repository at this point in the history
…4599)

- actually set the PARALLEL_DOWNLOADS parameter to use #4468
- return a 404 rather than a 500 if a ledger is missing as its more descriptive
- handle `count = 0` in average metric calculations
  • Loading branch information
Shaptic authored Sep 20, 2022
1 parent f6dad54 commit 02dab00
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion exp/lighthorizon/actions/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package actions
import (
"errors"
"net/http"
"os"
"strconv"

"github.com/stellar/go/support/log"
Expand Down Expand Up @@ -69,7 +70,11 @@ func NewTXByAccountHandler(lightHorizon services.LightHorizon) func(http.Respons
txns, err := lightHorizon.Transactions.GetTransactionsByAccount(ctx, paginate.Cursor, paginate.Limit, accountId)
if err != nil {
log.Error(err)
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
if os.IsNotExist(err) {
sendErrorResponse(r.Context(), w, supportProblem.NotFound)
} else if err != nil {
sendErrorResponse(r.Context(), w, supportProblem.ServerError)
}
return
}

Expand Down
1 change: 1 addition & 0 deletions exp/lighthorizon/build/k8s/lighthorizon_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data:
TXMETA_SOURCE: "s3://horizon-ledgermeta-prodnet-test"
INDEXES_SOURCE: "s3://horizon-index-prodnet-test"
NETWORK_PASSPHRASE: "Public Global Stellar Network ; September 2015"
MAX_PARALLEL_DOWNLOADS: 16
CACHE_PATH: "/ledgercache"
---
apiVersion: v1
Expand Down
1 change: 1 addition & 0 deletions exp/lighthorizon/build/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ COPY --from=builder /go/bin/lighthorizon ./
ENTRYPOINT ./lighthorizon serve \
--network-passphrase "$NETWORK_PASSPHRASE" \
--ledger-cache "$CACHE_PATH" \
--parallel-downloads "$MAX_PARALLEL_DOWNLOADS" \
"$TXMETA_SOURCE" "$INDEXES_SOURCE" \
3 changes: 3 additions & 0 deletions exp/lighthorizon/services/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,8 @@ func searchAccountTransactions(ctx context.Context,
func getAverageDuration[
T constraints.Signed | constraints.Float,
](d time.Duration, count T) time.Duration {
if count == 0 {
return 0 // don't bomb on div-by-zero
}
return time.Duration(int64(float64(d.Nanoseconds()) / float64(count)))
}

0 comments on commit 02dab00

Please sign in to comment.