-
Notifications
You must be signed in to change notification settings - Fork 107
/
config.go
55 lines (47 loc) · 1.56 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Package config implements global configuration options.
package config
import (
"time"
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/db"
)
// Config is the storage worker configuration structure.
type Config struct {
// Storage backend.
Backend string `yaml:"backend"`
// Maximum in-memory cache size.
MaxCacheSize string `yaml:"max_cache_size"`
// Number of concurrent storage diff fetchers.
FetcherCount uint `yaml:"fetcher_count"`
// Enable storage RPC access for all nodes.
PublicRPCEnabled bool `yaml:"public_rpc_enabled,omitempty"`
// Disable initial storage sync from checkpoints.
CheckpointSyncDisabled bool `yaml:"checkpoint_sync_disabled,omitempty"`
// Storage checkpointer configuration.
Checkpointer CheckpointerConfig `yaml:"checkpointer,omitempty"`
}
// CheckpointerConfig is the storage worker checkpointer configuration structure.
type CheckpointerConfig struct {
// Enable the storage checkpointer.
Enabled bool `yaml:"enabled"`
// Storage checkpointer check interval.
CheckInterval time.Duration `yaml:"check_interval"`
}
// Validate validates the configuration settings.
func (c *Config) Validate() error {
_, err := db.GetBackendByName(c.Backend)
return err
}
// DefaultConfig returns the default configuration settings.
func DefaultConfig() Config {
return Config{
Backend: "badger",
MaxCacheSize: "64mb",
FetcherCount: 4,
PublicRPCEnabled: false,
CheckpointSyncDisabled: false,
Checkpointer: CheckpointerConfig{
Enabled: false,
CheckInterval: 1 * time.Minute,
},
}
}