-
Notifications
You must be signed in to change notification settings - Fork 199
/
trieStorageManagerFactory.go
53 lines (45 loc) · 1.19 KB
/
trieStorageManagerFactory.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
package trie
import (
"github.com/ElrondNetwork/elrond-go/common"
)
// StorageManagerOptions specify the options that a trie storage manager can have
type StorageManagerOptions struct {
PruningEnabled bool
SnapshotsEnabled bool
CheckpointsEnabled bool
}
// CreateTrieStorageManager creates a new trie storage manager based on the given type
func CreateTrieStorageManager(
args NewTrieStorageManagerArgs,
options StorageManagerOptions,
) (common.StorageManager, error) {
log.Debug("trie storage manager options",
"trie pruning status", options.PruningEnabled,
"trie snapshot status", options.SnapshotsEnabled,
"trie checkpoints status", options.CheckpointsEnabled,
)
var tsm common.StorageManager
tsm, err := NewTrieStorageManager(args)
if err != nil {
return nil, err
}
if !options.PruningEnabled {
tsm, err = NewTrieStorageManagerWithoutPruning(tsm)
if err != nil {
return nil, err
}
}
if !options.SnapshotsEnabled {
tsm, err = NewTrieStorageManagerWithoutSnapshot(tsm)
if err != nil {
return nil, err
}
}
if !options.CheckpointsEnabled {
tsm, err = NewTrieStorageManagerWithoutCheckpoints(tsm)
if err != nil {
return nil, err
}
}
return tsm, nil
}