channeldb: inject clock into database
Use our standard clock mock for database time queries.
This commit is contained in:
7 files changed
+29
-15
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package channeldb
|
||||
|
||||
import "github.com/lightningnetwork/lnd/clock"
|
||||
|
||||
const (
|
||||
// DefaultRejectCacheSize is the default number of rejectCacheEntries to
|
||||
// cache for use in the rejection cache of incoming gossip traffic. This
|
||||
@@ -26,6 +28,9 @@ type Options struct {
|
||||
// freelist to disk, resulting in improved performance at the expense of
|
||||
// increased startup time.
|
||||
NoFreelistSync bool
|
||||
|
||||
// clock is the time source used by the database.
|
||||
clock clock.Clock
|
||||
}
|
||||
|
||||
// DefaultOptions returns an Options populated with default values.
|
||||
@@ -34,6 +39,7 @@ func DefaultOptions() Options {
|
||||
RejectCacheSize: DefaultRejectCacheSize,
|
||||
ChannelCacheSize: DefaultChannelCacheSize,
|
||||
NoFreelistSync: true,
|
||||
clock: clock.NewDefaultClock(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,3 +66,10 @@ func OptionSetSyncFreelist(b bool) OptionModifier {
|
||||
o.NoFreelistSync = !b
|
||||
}
|
||||
}
|
||||
|
||||
// OptionClock sets a non-default clock dependency.
|
||||
func OptionClock(clock clock.Clock) OptionModifier {
|
||||
return func(o *Options) {
|
||||
o.clock = clock
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user