-
Notifications
You must be signed in to change notification settings - Fork 199
/
hardforkStorerStub.go
58 lines (47 loc) · 1.4 KB
/
hardforkStorerStub.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
package mock
// HardforkStorerStub -
type HardforkStorerStub struct {
WriteCalled func(identifier string, key []byte, value []byte) error
FinishedIdentifierCalled func(identifier string) error
RangeKeysCalled func(handler func(identifier string, keys [][]byte) bool)
GetCalled func(identifier string, key []byte) ([]byte, error)
CloseCalled func() error
}
// Write -
func (hss *HardforkStorerStub) Write(identifier string, key []byte, value []byte) error {
if hss.WriteCalled != nil {
return hss.WriteCalled(identifier, key, value)
}
return nil
}
// FinishedIdentifier -
func (hss *HardforkStorerStub) FinishedIdentifier(identifier string) error {
if hss.FinishedIdentifierCalled != nil {
return hss.FinishedIdentifierCalled(identifier)
}
return nil
}
// RangeKeys -
func (hss *HardforkStorerStub) RangeKeys(handler func(identifier string, keys [][]byte) bool) {
if hss.RangeKeysCalled != nil {
hss.RangeKeysCalled(handler)
}
}
// Get -
func (hss *HardforkStorerStub) Get(identifier string, key []byte) ([]byte, error) {
if hss.GetCalled != nil {
return hss.GetCalled(identifier, key)
}
return make([]byte, 0), nil
}
// Close -
func (hss *HardforkStorerStub) Close() error {
if hss.CloseCalled != nil {
return hss.CloseCalled()
}
return nil
}
// IsInterfaceNil -
func (hss *HardforkStorerStub) IsInterfaceNil() bool {
return hss == nil
}