You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
607 B
29 lines
607 B
3 years ago
|
package tikv_manage
|
||
|
|
||
|
import (
|
||
|
"sync"
|
||
|
|
||
|
"github.com/ethereum/go-ethereum/ethdb"
|
||
|
"github.com/harmony-one/harmony/internal/tikv/statedb_cache"
|
||
|
)
|
||
|
|
||
|
type TiKvFactory interface {
|
||
|
NewChainDB(shardID uint32) (ethdb.Database, error)
|
||
|
NewStateDB(shardID uint32) (ethdb.Database, error)
|
||
|
NewCacheStateDB(shardID uint32) (*statedb_cache.StateDBCacheDatabase, error)
|
||
|
CloseAllDB()
|
||
|
}
|
||
|
|
||
|
var tikvInit = sync.Once{}
|
||
|
var tikvFactory TiKvFactory
|
||
|
|
||
|
func SetDefaultTiKVFactory(factory TiKvFactory) {
|
||
|
tikvInit.Do(func() {
|
||
|
tikvFactory = factory
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func GetDefaultTiKVFactory() (factory TiKvFactory) {
|
||
|
return tikvFactory
|
||
|
}
|