Skip to content

Commit

Permalink
set custom badger options
Browse files Browse the repository at this point in the history
  • Loading branch information
ukane-philemon committed Dec 21, 2022
1 parent 8eaec10 commit 7e3a521
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 10 additions & 3 deletions stakedb/ticketpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,21 @@ func dbVersion(db *badger.DB) (uint32, error) {
})
}

func badgerOptions(badgerDbPath string) badger.Options {
opts := badger.DefaultOptions(badgerDbPath)
opts.DetectConflicts = false
opts.CompactL0OnClose = true
opts.MetricsEnabled = false
opts.Logger = &badgerLogger{log}
return opts
}

// NewTicketPool constructs a TicketPool by opening the persistent diff db,
// loading all known diffs, initializing the TicketPool values.
func NewTicketPool(dataDir, dbSubDir string) (tp *TicketPool, err error) {
// Open ticket pool diffs database
badgerDbPath := filepath.Join(dataDir, dbSubDir)
opts := badger.DefaultOptions(badgerDbPath)
opts.MetricsEnabled = false
opts.Logger = &badgerLogger{log}
opts := badgerOptions(badgerDbPath)
db, err := badger.Open(opts)
if err != nil {
if !strings.Contains(err.Error(), "manifest has unsupported version") {
Expand Down
4 changes: 1 addition & 3 deletions stakedb/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ func v2Upgrade(dbPath string) error {
return fmt.Errorf("failed to delete db file: %w", err)
}

opts := badger.DefaultOptions(dbPath)
opts.MetricsEnabled = false
opts.Logger = &badgerLogger{log}
opts := badgerOptions(dbPath)
db, err := badger.Open(opts)
if err != nil {
return err
Expand Down

0 comments on commit 7e3a521

Please sign in to comment.