-
Notifications
You must be signed in to change notification settings - Fork 199
/
trieStorageManagerWithoutSnapshot.go
62 lines (50 loc) · 2.13 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
package trie
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-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(_ []byte, _ []byte, leavesChan chan core.KeyValueHolder, _ chan error, stats common.SnapshotStatisticsHandler, _ uint32) {
safelyCloseChan(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
}