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

exp/lighthorizon: Minor error-handling and deployment improvements. #4599

Merged
merged 1 commit into from
Sep 20, 2022
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
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)))
}