mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-02 08:58:38 +02:00
graph/db: rename Options to KVStoreOptions
Namespace these options so that we can introduce separate options for the new ChannelGraph.
This commit is contained in:
parent
ae3961b47f
commit
81e0608c10
@ -1026,7 +1026,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
"instances")
|
||||
}
|
||||
|
||||
graphDBOptions := []graphdb.OptionModifier{
|
||||
graphDBOptions := []graphdb.KVStoreOptionModifier{
|
||||
graphdb.WithRejectCacheSize(cfg.Caches.RejectCacheSize),
|
||||
graphdb.WithChannelCacheSize(cfg.Caches.ChannelCacheSize),
|
||||
graphdb.WithBatchCommitInterval(cfg.DB.BatchCommitInterval),
|
||||
|
@ -12,8 +12,8 @@ type ChannelGraph struct {
|
||||
}
|
||||
|
||||
// NewChannelGraph creates a new ChannelGraph instance with the given backend.
|
||||
func NewChannelGraph(db kvdb.Backend, options ...OptionModifier) (*ChannelGraph,
|
||||
error) {
|
||||
func NewChannelGraph(db kvdb.Backend, options ...KVStoreOptionModifier) (
|
||||
*ChannelGraph, error) {
|
||||
|
||||
store, err := NewKVStore(db, options...)
|
||||
if err != nil {
|
||||
|
@ -198,7 +198,7 @@ type KVStore struct {
|
||||
|
||||
// NewKVStore allocates a new KVStore backed by a DB instance. The
|
||||
// returned instance has its own unique reject cache and channel cache.
|
||||
func NewKVStore(db kvdb.Backend, options ...OptionModifier) (*KVStore,
|
||||
func NewKVStore(db kvdb.Backend, options ...KVStoreOptionModifier) (*KVStore,
|
||||
error) {
|
||||
|
||||
opts := DefaultOptions()
|
||||
@ -4827,8 +4827,8 @@ func (c *chanGraphNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo,
|
||||
|
||||
// MakeTestGraph creates a new instance of the KVStore for testing
|
||||
// purposes.
|
||||
func MakeTestGraph(t testing.TB, modifiers ...OptionModifier) (*ChannelGraph,
|
||||
error) {
|
||||
func MakeTestGraph(t testing.TB, modifiers ...KVStoreOptionModifier) (
|
||||
*ChannelGraph, error) {
|
||||
|
||||
opts := DefaultOptions()
|
||||
for _, modifier := range modifiers {
|
||||
|
@ -20,8 +20,8 @@ const (
|
||||
DefaultPreAllocCacheNumNodes = 15000
|
||||
)
|
||||
|
||||
// Options holds parameters for tuning and customizing a graph.DB.
|
||||
type Options struct {
|
||||
// KVStoreOptions holds parameters for tuning and customizing a graph.DB.
|
||||
type KVStoreOptions struct {
|
||||
// RejectCacheSize is the maximum number of rejectCacheEntries to hold
|
||||
// in the rejection cache.
|
||||
RejectCacheSize int
|
||||
@ -49,9 +49,9 @@ type Options struct {
|
||||
NoMigration bool
|
||||
}
|
||||
|
||||
// DefaultOptions returns an Options populated with default values.
|
||||
func DefaultOptions() *Options {
|
||||
return &Options{
|
||||
// DefaultOptions returns a KVStoreOptions populated with default values.
|
||||
func DefaultOptions() *KVStoreOptions {
|
||||
return &KVStoreOptions{
|
||||
RejectCacheSize: DefaultRejectCacheSize,
|
||||
ChannelCacheSize: DefaultChannelCacheSize,
|
||||
PreAllocCacheNumNodes: DefaultPreAllocCacheNumNodes,
|
||||
@ -60,41 +60,42 @@ func DefaultOptions() *Options {
|
||||
}
|
||||
}
|
||||
|
||||
// OptionModifier is a function signature for modifying the default Options.
|
||||
type OptionModifier func(*Options)
|
||||
// KVStoreOptionModifier is a function signature for modifying the default
|
||||
// KVStoreOptions.
|
||||
type KVStoreOptionModifier func(*KVStoreOptions)
|
||||
|
||||
// WithRejectCacheSize sets the RejectCacheSize to n.
|
||||
func WithRejectCacheSize(n int) OptionModifier {
|
||||
return func(o *Options) {
|
||||
func WithRejectCacheSize(n int) KVStoreOptionModifier {
|
||||
return func(o *KVStoreOptions) {
|
||||
o.RejectCacheSize = n
|
||||
}
|
||||
}
|
||||
|
||||
// WithChannelCacheSize sets the ChannelCacheSize to n.
|
||||
func WithChannelCacheSize(n int) OptionModifier {
|
||||
return func(o *Options) {
|
||||
func WithChannelCacheSize(n int) KVStoreOptionModifier {
|
||||
return func(o *KVStoreOptions) {
|
||||
o.ChannelCacheSize = n
|
||||
}
|
||||
}
|
||||
|
||||
// WithPreAllocCacheNumNodes sets the PreAllocCacheNumNodes to n.
|
||||
func WithPreAllocCacheNumNodes(n int) OptionModifier {
|
||||
return func(o *Options) {
|
||||
func WithPreAllocCacheNumNodes(n int) KVStoreOptionModifier {
|
||||
return func(o *KVStoreOptions) {
|
||||
o.PreAllocCacheNumNodes = n
|
||||
}
|
||||
}
|
||||
|
||||
// WithBatchCommitInterval sets the batch commit interval for the interval batch
|
||||
// schedulers.
|
||||
func WithBatchCommitInterval(interval time.Duration) OptionModifier {
|
||||
return func(o *Options) {
|
||||
func WithBatchCommitInterval(interval time.Duration) KVStoreOptionModifier {
|
||||
return func(o *KVStoreOptions) {
|
||||
o.BatchCommitInterval = interval
|
||||
}
|
||||
}
|
||||
|
||||
// WithUseGraphCache sets the UseGraphCache option to the given value.
|
||||
func WithUseGraphCache(use bool) OptionModifier {
|
||||
return func(o *Options) {
|
||||
func WithUseGraphCache(use bool) KVStoreOptionModifier {
|
||||
return func(o *KVStoreOptions) {
|
||||
o.UseGraphCache = use
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user