mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 19:22:40 +01:00
channeldb: add freelist sync option modifier
This commit is contained in:
parent
194a9dea81
commit
fa96450db8
@ -85,7 +85,7 @@ func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
|
|||||||
// Specify bbolt freelist options to reduce heap pressure in case the
|
// Specify bbolt freelist options to reduce heap pressure in case the
|
||||||
// freelist grows to be very large.
|
// freelist grows to be very large.
|
||||||
options := &bbolt.Options{
|
options := &bbolt.Options{
|
||||||
NoFreelistSync: true,
|
NoFreelistSync: opts.NoFreelistSync,
|
||||||
FreelistType: bbolt.FreelistMapType,
|
FreelistType: bbolt.FreelistMapType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@ type Options struct {
|
|||||||
// ChannelCacheSize is the maximum number of ChannelEdges to hold in the
|
// ChannelCacheSize is the maximum number of ChannelEdges to hold in the
|
||||||
// channel cache.
|
// channel cache.
|
||||||
ChannelCacheSize int
|
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.
|
// DefaultOptions returns an Options populated with default values.
|
||||||
@ -28,6 +33,7 @@ func DefaultOptions() Options {
|
|||||||
return Options{
|
return Options{
|
||||||
RejectCacheSize: DefaultRejectCacheSize,
|
RejectCacheSize: DefaultRejectCacheSize,
|
||||||
ChannelCacheSize: DefaultChannelCacheSize,
|
ChannelCacheSize: DefaultChannelCacheSize,
|
||||||
|
NoFreelistSync: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,3 +53,10 @@ func OptionSetChannelCacheSize(n int) OptionModifier {
|
|||||||
o.ChannelCacheSize = n
|
o.ChannelCacheSize = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OptionSetSyncFreelist allows the database to sync its freelist.
|
||||||
|
func OptionSetSyncFreelist(b bool) OptionModifier {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.NoFreelistSync = !b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user