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

config: Add MaxBlockHistoryLookback option #5749

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ type Local struct {
// i.e. the ledger can answer account states questions for the range Latest-MaxAcctLookback...Latest
MaxAcctLookback uint64 `version[23]:"4"`

// BlockHistoryLookback sets the max lookback range for block information.
// i.e. the block DB can return transaction IDs for questions for the range Latest-MaxBlockHistoryLookback...Latest
MaxBlockHistoryLookback uint64 `version[32]:"0"`

// EnableUsageLog enables 10Hz log of CPU and RAM usage.
// Also adds 'algod_ram_usage` (number of bytes in use) to /metrics
EnableUsageLog bool `version[24]:"false"`
Expand Down
5 changes: 5 additions & 0 deletions ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ func (l *Ledger) notifyCommit(r basics.Round) basics.Round {
}()
minToSave := l.trackers.committedUpTo(r)

// Check if additional block history is configured, and adjust minToSave if so.
if configuredMinToSave := r.SubSaturate(basics.Round(l.cfg.MaxBlockHistoryLookback)); configuredMinToSave < minToSave {
winder marked this conversation as resolved.
Show resolved Hide resolved
minToSave = configuredMinToSave
}

if l.archival {
// Do not forget any blocks.
minToSave = 0
Expand Down