mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
server+htlcswitch: auto compact sphinx DB too
This commit is contained in:
@@ -51,7 +51,7 @@ type DecayedLog struct {
|
||||
started int32 // To be used atomically.
|
||||
stopped int32 // To be used atomically.
|
||||
|
||||
dbPath string
|
||||
cfg *kvdb.BoltBackendConfig
|
||||
|
||||
db kvdb.Backend
|
||||
|
||||
@@ -64,16 +64,24 @@ type DecayedLog struct {
|
||||
// NewDecayedLog creates a new DecayedLog, which caches recently seen hash
|
||||
// shared secrets. Entries are evicted as their cltv expires using block epochs
|
||||
// from the given notifier.
|
||||
func NewDecayedLog(dbPath string,
|
||||
func NewDecayedLog(dbPath, dbFileName string, boltCfg *kvdb.BoltConfig,
|
||||
notifier chainntnfs.ChainNotifier) *DecayedLog {
|
||||
|
||||
cfg := &kvdb.BoltBackendConfig{
|
||||
DBPath: dbPath,
|
||||
DBFileName: dbFileName,
|
||||
NoFreelistSync: true,
|
||||
AutoCompact: boltCfg.AutoCompact,
|
||||
AutoCompactMinAge: boltCfg.AutoCompactMinAge,
|
||||
}
|
||||
|
||||
// Use default path for log database
|
||||
if dbPath == "" {
|
||||
dbPath = defaultDbDirectory
|
||||
cfg.DBPath = defaultDbDirectory
|
||||
}
|
||||
|
||||
return &DecayedLog{
|
||||
dbPath: dbPath,
|
||||
cfg: cfg,
|
||||
notifier: notifier,
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
@@ -89,9 +97,7 @@ func (d *DecayedLog) Start() error {
|
||||
|
||||
// Open the boltdb for use.
|
||||
var err error
|
||||
d.db, err = kvdb.Create(
|
||||
kvdb.BoltBackendName, d.dbPath, true,
|
||||
)
|
||||
d.db, err = kvdb.GetBoltBackend(d.cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not open boltdb: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user