mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
channeldb: add freelist sync option modifier
This commit is contained in:
parent
194a9dea81
commit
fa96450db8
2 changed files with 14 additions and 1 deletions
|
@ -85,7 +85,7 @@ func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
|
|||
// Specify bbolt freelist options to reduce heap pressure in case the
|
||||
// freelist grows to be very large.
|
||||
options := &bbolt.Options{
|
||||
NoFreelistSync: true,
|
||||
NoFreelistSync: opts.NoFreelistSync,
|
||||
FreelistType: bbolt.FreelistMapType,
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@ type Options struct {
|
|||
// ChannelCacheSize is the maximum number of ChannelEdges to hold in the
|
||||
// channel cache.
|
||||
ChannelCacheSize int
|
||||
|
||||
// NoFreelistSync, if true, prevents the database from syncing its
|
||||
// freelist to disk, resulting in improved performance at the expense of
|
||||
// increased startup time.
|
||||
NoFreelistSync bool
|
||||
}
|
||||
|
||||
// DefaultOptions returns an Options populated with default values.
|
||||
|
@ -28,6 +33,7 @@ func DefaultOptions() Options {
|
|||
return Options{
|
||||
RejectCacheSize: DefaultRejectCacheSize,
|
||||
ChannelCacheSize: DefaultChannelCacheSize,
|
||||
NoFreelistSync: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,3 +53,10 @@ func OptionSetChannelCacheSize(n int) OptionModifier {
|
|||
o.ChannelCacheSize = n
|
||||
}
|
||||
}
|
||||
|
||||
// OptionSetSyncFreelist allows the database to sync its freelist.
|
||||
func OptionSetSyncFreelist(b bool) OptionModifier {
|
||||
return func(o *Options) {
|
||||
o.NoFreelistSync = !b
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue