-
Notifications
You must be signed in to change notification settings - Fork 1
/
nilStorer.go
88 lines (70 loc) · 1.94 KB
/
nilStorer.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
package storageUnit
import (
storageCore "github.com/ElrondNetwork/elrond-go-core/storage"
"github.com/ElrondNetwork/elrond-go-storage/common"
)
// NilStorer resembles a disabled implementation of the Storer interface
type NilStorer struct {
}
// NewNilStorer will return a nil storer
func NewNilStorer() *NilStorer {
return new(NilStorer)
}
// GetFromEpoch will do nothing
func (ns *NilStorer) GetFromEpoch(_ []byte, _ uint32) ([]byte, error) {
return nil, nil
}
// GetBulkFromEpoch will do nothing
func (ns *NilStorer) GetBulkFromEpoch(_ [][]byte, _ uint32) ([]storageCore.KeyValuePair, error) {
return nil, nil
}
// SearchFirst will do nothing
func (ns *NilStorer) SearchFirst(_ []byte) ([]byte, error) {
return nil, nil
}
// Put will do nothing
func (ns *NilStorer) Put(_, _ []byte) error {
return nil
}
// PutInEpoch will do nothing
func (ns *NilStorer) PutInEpoch(_, _ []byte, _ uint32) error {
return nil
}
// GetOldestEpoch will return an error that signals that the oldest epoch fetching is not available
func (ns *NilStorer) GetOldestEpoch() (uint32, error) {
return 0, common.ErrOldestEpochNotAvailable
}
// Close will do nothing
func (ns *NilStorer) Close() error {
return nil
}
// Get will do nothing
func (ns *NilStorer) Get(_ []byte) ([]byte, error) {
return nil, nil
}
// Has will do nothing
func (ns *NilStorer) Has(_ []byte) error {
return nil
}
// RemoveFromCurrentEpoch will do nothing
func (ns *NilStorer) RemoveFromCurrentEpoch(_ []byte) error {
return nil
}
// Remove will do nothing
func (ns *NilStorer) Remove(_ []byte) error {
return nil
}
// ClearCache will do nothing
func (ns *NilStorer) ClearCache() {
}
// DestroyUnit will do nothing
func (ns *NilStorer) DestroyUnit() error {
return nil
}
// RangeKeys does nothing
func (ns *NilStorer) RangeKeys(_ func(key []byte, val []byte) bool) {
}
// IsInterfaceNil returns true if there is no value under the interface
func (ns *NilStorer) IsInterfaceNil() bool {
return ns == nil
}