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: Add parameters to preload ledger cache. #4615

Merged
merged 5 commits into from
Oct 11, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Check that startLedger is valid
  • Loading branch information
Shaptic committed Oct 11, 2022
commit 267757e69bf1cd33761696eb87595a183272fce7
13 changes: 9 additions & 4 deletions exp/lighthorizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,25 @@ break down accounts by active ledgers.`,
if cachePreloadCount > 0 {
if cacheDir == "" {
log.Fatalf("--ledger-cache-preload=%d specified but no "+
"--ledger-cache directory provided, ignoring...",
"--ledger-cache directory provided.",
cachePreloadCount)
return
} else {
startLedger := latestLedger - cachePreloadCount
startLedger := int(latestLedger) - int(cachePreloadCount)
if cachePreloadStart > 0 {
startLedger = cachePreloadStart
startLedger = int(cachePreloadStart)
}
if startLedger <= 0 {
log.Warnf("Starting ledger invalid (%d), defaulting to 2.",
startLedger)
startLedger = 2
}

log.Infof("Preloading cache at %s with %d ledgers, starting at ledger %d.",
cacheDir, startLedger, cachePreloadCount)
go func() {
tools.BuildCache(sourceUrl, cacheDir,
startLedger, cachePreloadCount, false)
uint32(startLedger), cachePreloadCount, false)
}()
}
}
Expand Down