-
Notifications
You must be signed in to change notification settings - Fork 199
/
trieStorageManagerWithoutSnapshot.go
63 lines (51 loc) · 2.15 KB
/
trieStorageManagerWithoutSnapshot.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
package trie
import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-go/common"
)
type trieStorageManagerWithoutSnapshot struct {
common.StorageManager
}
// NewTrieStorageManagerWithoutSnapshot creates a new trieStorageManagerWithoutSnapshot
func NewTrieStorageManagerWithoutSnapshot(tsm common.StorageManager) (*trieStorageManagerWithoutSnapshot, error) {
if check.IfNil(tsm) {
return nil, ErrNilTrieStorage
}
return &trieStorageManagerWithoutSnapshot{
StorageManager: tsm,
}, nil
}
// GetFromCurrentEpoch calls Get(), as this implementation uses a static storer
func (tsm *trieStorageManagerWithoutSnapshot) GetFromCurrentEpoch(key []byte) ([]byte, error) {
return tsm.Get(key)
}
// PutInEpoch calls Put(), as this implementation uses a static storer
func (tsm *trieStorageManagerWithoutSnapshot) PutInEpoch(key []byte, val []byte, _ uint32) error {
return tsm.Put(key, val)
}
// PutInEpochWithoutCache calls Put(), as this implementation uses a static storer
func (tsm *trieStorageManagerWithoutSnapshot) PutInEpochWithoutCache(key []byte, val []byte, _ uint32) error {
return tsm.Put(key, val)
}
// TakeSnapshot does nothing, as snapshots are disabled for this implementation
func (tsm *trieStorageManagerWithoutSnapshot) TakeSnapshot(_ string, _ []byte, _ []byte, iteratorChannels *common.TrieIteratorChannels, _ chan []byte, stats common.SnapshotStatisticsHandler, _ uint32) {
if iteratorChannels != nil {
safelyCloseChan(iteratorChannels.LeavesChan)
}
stats.SnapshotFinished()
}
// GetLatestStorageEpoch returns 0, as this implementation uses a static storer
func (tsm *trieStorageManagerWithoutSnapshot) GetLatestStorageEpoch() (uint32, error) {
return 0, nil
}
// SetEpochForPutOperation does nothing for this implementation
func (tsm *trieStorageManagerWithoutSnapshot) SetEpochForPutOperation(uint32) {
}
// ShouldTakeSnapshot returns false for this implementation
func (tsm *trieStorageManagerWithoutSnapshot) ShouldTakeSnapshot() bool {
return false
}
// IsInterfaceNil returns true if there is no value under the interface
func (tsm *trieStorageManagerWithoutSnapshot) IsInterfaceNil() bool {
return tsm == nil
}