-
Notifications
You must be signed in to change notification settings - Fork 199
/
unitOpener.go
33 lines (28 loc) · 982 Bytes
/
unitOpener.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
package storage
import (
"github.com/ElrondNetwork/elrond-go/config"
"github.com/ElrondNetwork/elrond-go/storage"
)
// UnitOpenerStub -
type UnitOpenerStub struct {
OpenDBCalled func(dbConfig config.DBConfig, shardID uint32, epoch uint32) (storage.Storer, error)
GetMostRecentStorageUnitCalled func(config config.DBConfig) (storage.Storer, error)
}
// OpenDB -
func (uohs *UnitOpenerStub) OpenDB(dbConfig config.DBConfig, shardID uint32, epoch uint32) (storage.Storer, error) {
if uohs.OpenDBCalled != nil {
return uohs.OpenDBCalled(dbConfig, shardID, epoch)
}
return &StorerStub{}, nil
}
// GetMostRecentStorageUnit -
func (uohs *UnitOpenerStub) GetMostRecentStorageUnit(config config.DBConfig) (storage.Storer, error) {
if uohs.GetMostRecentStorageUnitCalled != nil {
return uohs.GetMostRecentStorageUnitCalled(config)
}
return &StorerStub{}, nil
}
// IsInterfaceNil -
func (uohs *UnitOpenerStub) IsInterfaceNil() bool {
return uohs == nil
}