Skip to content

Commit 1da383b

Browse files
committed
Merge branch 'ryan/allow-disable-history-drop' into 'main'
Allow history drop to be disabled See merge request flarenetwork/FSP/flare-system-c-chain-indexer!68
2 parents e73f44e + 2258c0e commit 1da383b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ username = "root"
4949
password = "root"
5050
log_queries = false
5151
drop_table_at_start = true
52-
history_drop = 604800 # Enable deleting the transactions and logs in DB that are older (timestamp of the block) than history_drop (in seconds); set 0 or skip to turn off; defaults to 7 days for Flare/Songbird and 2 days for Coston*
52+
history_drop = 604800 # Enable deleting the transactions and logs in DB that are older (timestamp of the block) than history_drop (in seconds); set 0 to turn off; defaults to 7 days for Flare/Songbird and 2 days for Coston*
5353

5454
[logger]
5555
level = "INFO"

config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ func (db *DBConfig) GetHistoryDrop(ctx context.Context, chainIDBig *big.Int) (ui
105105
return minHistoryDropSeconds, nil // Use default if not set
106106
}
107107

108-
if *db.HistoryDrop < minHistoryDropSeconds {
108+
historyDrop := *db.HistoryDrop
109+
if historyDrop != 0 && historyDrop < minHistoryDropSeconds {
109110
return 0, errors.Errorf(
110111
"history drop must be at least %d seconds, got %d seconds",
111112
minHistoryDropSeconds,
112113
db.HistoryDrop,
113114
)
114115
}
115116

116-
return *db.HistoryDrop, nil
117+
return historyDrop, nil
117118
}
118119

119120
type ChainConfig struct {

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func run(ctx context.Context) error {
8080
if cfg.DB.HistoryDrop == nil {
8181
logger.Info("Using default history drop value of %.1f days", historyDropDays)
8282
} else {
83-
logger.Info("Using configured history drop value of %.1f days", historyDropDays)
83+
if *cfg.DB.HistoryDrop == 0 {
84+
logger.Info("History drop disabled")
85+
} else {
86+
logger.Info("Using configured history drop value of %.1f days", historyDropDays)
87+
}
8488
}
8589

8690
if historyDrop > 0 {

0 commit comments

Comments
 (0)