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

Services/horizon: Reduce log output #4977

Merged
merged 1 commit into from
Jul 27, 2023
Merged
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
10 changes: 9 additions & 1 deletion services/horizon/internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"
Expand Down Expand Up @@ -196,6 +197,13 @@ func (a *App) Paths() paths.Finder {
return a.paths
}

func isLocalAddress(url string, port uint) bool {
localHostURL := fmt.Sprintf("http://localhost:%d", port)
localIPURL := fmt.Sprintf("http://127.0.0.1:%d", port)

return strings.HasPrefix(url, localHostURL) || strings.HasPrefix(url, localIPURL)
}

// UpdateCoreLedgerState triggers a refresh of Stellar-Core ledger state.
// This is done separately from Horizon ledger state update to prevent issues
// in case Stellar-Core query timeout.
Expand All @@ -205,7 +213,7 @@ func (a *App) UpdateCoreLedgerState(ctx context.Context) {
// #4446 If the ingestion state machine is in the build state, the query can time out
// because the captive-core buffer may be full. In this case, skip the check.
if a.config.CaptiveCoreToml != nil &&
a.config.StellarCoreURL == fmt.Sprintf("http://localhost:%d", a.config.CaptiveCoreToml.HTTPPort) &&
isLocalAddress(a.config.StellarCoreURL, a.config.CaptiveCoreToml.HTTPPort) &&
a.ingester != nil && a.ingester.GetCurrentState() == ingest.Build {
return
}
Expand Down