-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathconfig.go
More file actions
61 lines (53 loc) · 1.75 KB
/
Copy pathconfig.go
File metadata and controls
61 lines (53 loc) · 1.75 KB
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
56
57
58
59
60
61
// 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"`
// ParallelChunker specifies if the new parallel chunking algorithm is used.
ParallelChunker bool `yaml:"parallel_chunker"`
}
// Validate validates the configuration settings.
func (c *Config) Validate() error {
if c.Backend != "auto" {
_, err := db.GetBackendByName(c.Backend)
return err
}
return nil
}
// DefaultConfig returns the default configuration settings.
func DefaultConfig() Config {
return Config{
Backend: "auto",
MaxCacheSize: "64mb",
FetcherCount: 4,
PublicRPCEnabled: false,
CheckpointSyncDisabled: false,
Checkpointer: CheckpointerConfig{
Enabled: false,
CheckInterval: 1 * time.Minute,
ParallelChunker: true,
},
}
}