-
Notifications
You must be signed in to change notification settings - Fork 199
/
trieStorageManagerWithoutPruning.go
105 lines (87 loc) · 3.04 KB
/
trieStorageManagerWithoutPruning.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package trie
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go/common"
)
// trieStorageManagerWithoutPruning manages the storage operations of the trie, but does not prune old values
type trieStorageManagerWithoutPruning struct {
*trieStorageManager
}
// NewTrieStorageManagerWithoutPruning creates a new instance of trieStorageManagerWithoutPruning
func NewTrieStorageManagerWithoutPruning(db common.DBWriteCacher) (*trieStorageManagerWithoutPruning, error) {
if check.IfNil(db) {
return nil, ErrNilDatabase
}
return &trieStorageManagerWithoutPruning{&trieStorageManager{mainStorer: db}}, nil
}
// Put adds only to the db
func (tsm *trieStorageManagerWithoutPruning) Put(key []byte, val []byte) error {
return tsm.mainStorer.Put(key, val)
}
// PutInEpoch adds only to the db
func (tsm *trieStorageManagerWithoutPruning) PutInEpoch(key []byte, val []byte, _ uint32) error {
return tsm.mainStorer.Put(key, val)
}
// Get checks only the db
func (tsm *trieStorageManagerWithoutPruning) Get(key []byte) ([]byte, error) {
return tsm.mainStorer.Get(key)
}
// GetFromCurrentEpoch checks only the db
func (tsm *trieStorageManagerWithoutPruning) GetFromCurrentEpoch(key []byte) ([]byte, error) {
return tsm.mainStorer.Get(key)
}
// TakeSnapshot does nothing if pruning is disabled
func (tsm *trieStorageManagerWithoutPruning) TakeSnapshot(
_ []byte,
_ []byte,
chLeaves chan core.KeyValueHolder,
_ chan error,
stats common.SnapshotStatisticsHandler,
_ uint32,
) {
if chLeaves != nil {
close(chLeaves)
}
stats.SnapshotFinished()
log.Trace("trieStorageManagerWithoutPruning - TakeSnapshot:trie storage pruning is disabled")
}
// SetCheckpoint does nothing if pruning is disabled
func (tsm *trieStorageManagerWithoutPruning) SetCheckpoint(
_ []byte,
_ []byte,
chLeaves chan core.KeyValueHolder,
_ chan error,
stats common.SnapshotStatisticsHandler,
) {
if chLeaves != nil {
close(chLeaves)
}
stats.SnapshotFinished()
log.Trace("trieStorageManagerWithoutPruning - SetCheckpoint:trie storage pruning is disabled")
}
// Close - closes all underlying components
func (tsm *trieStorageManagerWithoutPruning) Close() error {
log.Trace("trieStorageManagerWithoutPruning - Close:trie storage pruning is disabled")
return tsm.mainStorer.Close()
}
// IsPruningEnabled returns false if the trie pruning is disabled
func (tsm *trieStorageManagerWithoutPruning) IsPruningEnabled() bool {
return false
}
// AddDirtyCheckpointHashes does nothing for this implementation
func (tsm *trieStorageManagerWithoutPruning) AddDirtyCheckpointHashes(_ []byte, _ common.ModifiedHashes) bool {
return false
}
// ShouldTakeSnapshot returns false
func (tsm *trieStorageManagerWithoutPruning) ShouldTakeSnapshot() bool {
return false
}
// GetLatestStorageEpoch returns 0
func (tsm *trieStorageManagerWithoutPruning) GetLatestStorageEpoch() (uint32, error) {
return 0, nil
}
// Remove does nothing for this implementation
func (tsm *trieStorageManagerWithoutPruning) Remove(_ []byte) error {
return nil
}